Interface TransferManager

All Superinterfaces:
AutoCloseable

@BetaApi public interface TransferManager extends AutoCloseable
An interface for a Transfer Manager.

Transfer Manager handles Parallel Uploads and Parallel Downloads.

  • Method Details

    • uploadFiles

      @BetaApi @NonNull UploadJob uploadFiles(List<Path> files, ParallelUploadConfig config)
      Uploads a list of files in parallel. This operation will not block the invoking thread, awaiting results should be done on the returned UploadJob.

      Accepts a ParallelUploadConfig which defines the constraints of parallel uploads or predefined defaults.

      Example of creating a parallel upload with Transfer Manager.

      
       String bucketName = "my-unique-bucket";
       Path filePath = Paths.get("/path/to/my/file.txt");
       Path anotherFilePath = Paths.get("/path/to/another/file.txt");
       List<Path> files = List.of(filePath, anotherFilePath);
      
       ParallelUploadConfig parallelUploadConfig =
                 ParallelUploadConfig.newBuilder()
                     .setBucketName(bucketName)
                     .build();
      
       UploadJob uploadedFiles = transferManager.uploadFiles(files, config);
      
       
      Returns:
      an UploadJob
    • downloadBlobs

      @BetaApi @NonNull DownloadJob downloadBlobs(List<BlobInfo> blobs, ParallelDownloadConfig config)
      Downloads a list of blobs in parallel. This operation will not block the invoking thread, awaiting results should be done on the returned DownloadJob.

      Accepts a ParallelDownloadConfig which defines the constraints of parallel downloads or predefined defaults.

      Example of creating a parallel download with Transfer Manager.

      
       String bucketName = "my-unique-bucket";
       String blobName = "my-blob-name";
       BlobId blobId = BlobId.of(bucketName, blobName);
       BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
       Path baseDir = Paths.get("/path/to/directory/");
      
       ParallelDownloadConfig parallelDownloadConfig =
                 ParallelDownloadConfig.newBuilder()
                     .setBucketName(bucketName)
                     .setDownloadDirectory(baseDir)
                     .build();
      
       DownloadJob downloadedBlobs = transferManager.downloadBlobs(files, config);
      
       
      Returns:
      a DownloadJob