Interface TransferManager (2.37.0)

public interface TransferManager extends AutoCloseable

An interface for a Transfer Manager.

Transfer Manager handles Parallel Uploads and Parallel Downloads.

Implements

AutoCloseable

Methods

downloadBlobs(List<BlobInfo> blobs, ParallelDownloadConfig config)

public abstract @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);

 
Parameters
Name Description
blobs List<BlobInfo>
config ParallelDownloadConfig
Returns
Type Description
@org.checkerframework.checker.nullness.qual.NonNull com.google.cloud.storage.transfermanager.DownloadJob

a DownloadJob

uploadFiles(List<Path> files, ParallelUploadConfig config)

public abstract @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);

 
Parameters
Name Description
files List<Path>
config ParallelUploadConfig
Returns
Type Description
@org.checkerframework.checker.nullness.qual.NonNull com.google.cloud.storage.transfermanager.UploadJob

an UploadJob

Exceptions
Type Description
IOException