@BetaApi public interface TransferManager extends AutoCloseable
Transfer Manager handles Parallel Uploads and Parallel Downloads.
Modifier and Type | Method and Description |
---|---|
@NonNull DownloadJob |
downloadBlobs(List<BlobInfo> blobs,
ParallelDownloadConfig config)
Downloads a list of blobs in parallel.
|
@NonNull UploadJob |
uploadFiles(List<Path> files,
ParallelUploadConfig config)
Uploads a list of files in parallel.
|
close
@BetaApi @NonNull UploadJob uploadFiles(List<Path> files, ParallelUploadConfig config)
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);
UploadJob
@BetaApi @NonNull DownloadJob downloadBlobs(List<BlobInfo> blobs, ParallelDownloadConfig config)
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);
DownloadJob
Copyright © 2023 Google LLC. All rights reserved.