Interface TransferManager
- All Superinterfaces:
AutoCloseable
An interface for a Transfer Manager.
Transfer Manager handles Parallel Uploads and Parallel Downloads.
-
Method Summary
Modifier and TypeMethodDescription@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.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
uploadFiles
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
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
-