code: private void writeChunk(String spaceId, ChunkInputStream chunk)
          throws NotFoundException {
          // Write chunk as a temp file
          String chunkId = chunk.getChunkId();
          File chunkFile = IOUtil.writeStreamToFile(chunk);
  
          try {
              String chunkChecksum = getChunkChecksum(chunkFile);
  
              // Write chunk if it is not already in storage (or jumpstart is enabled)
              if (jumpStart || !chunkInStorage(spaceId, chunkId, chunkChecksum)) {
                  try {
                      createRetrier().execute(new Retriable() {
                          private int attempt = 0;
  
                          @Override
                          public Object retry() throws Exception {
                              attempt++;
                              try (InputStream chunkStream = new FileInputStream(chunkFile)) {
                                  ChunkInputStream chunkFileStream =
                                      new ChunkInputStream(chunkId,
                                                           chunkStream,
                                                           chunkFile.length(),
                                                           chunk.md5Preserved());
                                  writeSingle(spaceId, chunkChecksum, chunkFileStream, attempt == getMaxRetries() + 1);
                              }
                              return "";
                          }
                      });
  
                  } catch (Exception e) {
                      String err = "Failed to store chunk with ID " + chunkId +
                                   " in space " + spaceId + " after " + getMaxRetries() +
                                   " attempts. Last error: " + e.getMessage();
                      throw new DuraCloudRuntimeException(err, e);
                  }
              }
          } finally {
              if (null != chunkFile && chunkFile.exists()) {
                  FileUtils.deleteQuietly(chunkFile);
              }
          }
      }
docs: /*
  Writes chunk to DuraCloud if it does not already exist in DuraCloud with a
  matching checksum. Retry failed transfers.