const{Storage}=require('@google-cloud/storage');conststorage=newStorage();constbucket=storage.bucket('my-bucket');consttransferManager=newTransferManager(bucket);//-// Download a large file in chunks utilizing parallel operations.//-constresponse=awaittransferManager.downloadFileInChunks(bucket.file('large-file.txt');// Your local directory now contains:// - "large-file.txt" (with the contents from my-bucket.large-file.txt)
An array of file name strings or file objects to be downloaded. If a string is provided this will be treated as a GCS prefix and all files with that prefix will be downloaded.
Configuration options. Setting options.prefix or options.stripPrefix or options.passthroughOptions.destination will cause the downloaded files to be written to the file system instead of being returned as a buffer.
const{Storage}=require('@google-cloud/storage');conststorage=newStorage();constbucket=storage.bucket('my-bucket');consttransferManager=newTransferManager(bucket);//-// Download multiple files in parallel.//-constresponse=awaittransferManager.downloadManyFiles(['file1.txt','file2.txt']);// The following files have been downloaded:// - "file1.txt" (with the contents from my-bucket.file1.txt)// - "file2.txt" (with the contents from my-bucket.file2.txt)constresponse=awaittransferManager.downloadManyFiles([bucket.File('file1.txt'),bucket.File('file2.txt')]);// The following files have been downloaded:// - "file1.txt" (with the contents from my-bucket.file1.txt)// - "file2.txt" (with the contents from my-bucket.file2.txt)constresponse=awaittransferManager.downloadManyFiles('test-folder');// All files with GCS prefix of 'test-folder' have been downloaded.
Upload a large file in chunks utilizing parallel upload opertions. If the upload fails, an uploadId and map containing all the successfully uploaded parts will be returned to the caller. These arguments can be used to resume the upload.
A function that will return a type that implements the MPU interface. Most users will not need to use this.
Returns
Type
Description
Promise<GaxiosResponse| undefined>
{Promise
Example
const{Storage}=require('@google-cloud/storage');conststorage=newStorage();constbucket=storage.bucket('my-bucket');consttransferManager=newTransferManager(bucket);//-// Upload a large file in chunks utilizing parallel operations.//-constresponse=awaittransferManager.uploadFileInChunks('large-file.txt');// Your bucket now contains:// - "large-file.txt"
Upload multiple files in parallel to the bucket. This is a convenience method that utilizes to perform the upload.
Parameters
Name
Description
filePathsOrDirectory
string[] | string
An array of fully qualified paths to the files or a directory name. If a directory name is provided, the directory will be recursively walked and all files will be added to the upload list. to be uploaded to the bucket
const{Storage}=require('@google-cloud/storage');conststorage=newStorage();constbucket=storage.bucket('my-bucket');consttransferManager=newTransferManager(bucket);//-// Upload multiple files in parallel.//-constresponse=awaittransferManager.uploadManyFiles(['/local/path/file1.txt, 'local/path/file2.txt']);// Your bucket now contains:// - "local/path/file1.txt" (with the contents of '/local/path/file1.txt')// - "local/path/file2.txt" (with the contents of '/local/path/file2.txt')const response = await transferManager.uploadManyFiles('/local/directory');// Your bucket will now contain all files contained in '/local/directory'maintainingthesubdirectorystructure.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Class TransferManager (7.16.0)\n\nVersion latestkeyboard_arrow_down\n\n- [7.16.0 (latest)](/nodejs/docs/reference/storage/latest/storage/transfermanager)\n- [7.13.0](/nodejs/docs/reference/storage/7.13.0/storage/transfermanager)\n- [7.3.2](/nodejs/docs/reference/storage/7.3.2/storage/transfermanager)\n- [7.2.0](/nodejs/docs/reference/storage/7.2.0/storage/transfermanager)\n- [7.1.0](/nodejs/docs/reference/storage/7.1.0/storage/transfermanager)\n- [7.0.1](/nodejs/docs/reference/storage/7.0.1/storage/transfermanager)\n- [6.12.0](/nodejs/docs/reference/storage/6.12.0/storage/transfermanager)\n- [6.11.0](/nodejs/docs/reference/storage/6.11.0/storage/transfermanager)\n- [6.7.0](/nodejs/docs/reference/storage/6.7.0/storage/transfermanager)\n- [6.6.0](/nodejs/docs/reference/storage/6.6.0/storage/transfermanager)\n- [6.5.4](/nodejs/docs/reference/storage/6.5.4/storage/transfermanager)\n- [6.4.2](/nodejs/docs/reference/storage/6.4.2/storage/transfermanager)\n- [6.3.0](/nodejs/docs/reference/storage/6.3.0/storage/transfermanager)\n- [6.2.3](/nodejs/docs/reference/storage/6.2.3/storage/transfermanager)\n- [5.19.1](/nodejs/docs/reference/storage/5.19.1/storage/transfermanager)\n- [5.18.3](/nodejs/docs/reference/storage/5.18.3/storage/transfermanager)\n- [5.17.0](/nodejs/docs/reference/storage/5.17.0/storage/transfermanager)\n- [5.16.1](/nodejs/docs/reference/storage/5.16.1/storage/transfermanager)\n- [5.15.6](/nodejs/docs/reference/storage/5.15.6/storage/transfermanager)\n- [5.14.8](/nodejs/docs/reference/storage/5.14.8/storage/transfermanager)\n- [5.13.2](/nodejs/docs/reference/storage/5.13.2/storage/transfermanager)\n- [5.12.0](/nodejs/docs/reference/storage/5.12.0/storage/transfermanager)\n- [5.11.1](/nodejs/docs/reference/storage/5.11.1/storage/transfermanager)\n- [5.10.0](/nodejs/docs/reference/storage/5.10.0/storage/transfermanager)\n- [5.9.0](/nodejs/docs/reference/storage/5.9.0/storage/transfermanager)\n- [5.8.5](/nodejs/docs/reference/storage/5.8.5/storage/transfermanager) \nCreate a TransferManager object to perform parallel transfer operations on a Cloud Storage bucket.\n\nPackage\n-------\n\n[@google-cloud/storage](../overview.html)\n\nConstructors\n------------\n\n### (constructor)(bucket)\n\n constructor(bucket: Bucket);\n\nConstructs a new instance of the `TransferManager` class\n\nProperties\n----------\n\n### bucket\n\n bucket: Bucket;\n\nMethods\n-------\n\n### downloadFileInChunks(fileOrName, options)\n\n downloadFileInChunks(fileOrName: File | string, options?: DownloadFileInChunksOptions): Promise\u003cvoid | DownloadResponse\u003e;\n\nDownload a large file in chunks utilizing parallel download operations. This is a convenience method that utilizes to perform the download.\n\n**Example** \n\n\n const {Storage} = require('https://cloud.google.com/nodejs/docs/reference/storage/latest/overview.html');\n const storage = new Storage();\n const bucket = storage.bucket('my-bucket');\n const transferManager = new https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html(bucket);\n\n //-\n // Download a large file in chunks utilizing parallel operations.\n //-\n const response = await transferManager.https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html(bucket.file('large-file.txt');\n // Your local directory now contains:\n // - \"large-file.txt\" (with the contents from my-bucket.large-file.txt)\n\n### downloadManyFiles(filesOrFolder, options)\n\n downloadManyFiles(filesOrFolder: File[] | string[] | string, options?: DownloadManyFilesOptions): Promise\u003cvoid | DownloadResponse[]\u003e;\n\nDownload multiple files in parallel to the local filesystem. This is a convenience method that utilizes to perform the download.\n\n**Example** \n\n\n const {Storage} = require('https://cloud.google.com/nodejs/docs/reference/storage/latest/overview.html');\n const storage = new Storage();\n const bucket = storage.bucket('my-bucket');\n const transferManager = new https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html(bucket);\n\n //-\n // Download multiple files in parallel.\n //-\n const response = await transferManager.https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html(['file1.txt', 'file2.txt']);\n // The following files have been downloaded:\n // - \"file1.txt\" (with the contents from my-bucket.file1.txt)\n // - \"file2.txt\" (with the contents from my-bucket.file2.txt)\n const response = await transferManager.https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html([bucket.https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/storage_2.html('file1.txt'), bucket.https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/storage_2.html('file2.txt')]);\n // The following files have been downloaded:\n // - \"file1.txt\" (with the contents from my-bucket.file1.txt)\n // - \"file2.txt\" (with the contents from my-bucket.file2.txt)\n const response = await transferManager.https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html('test-folder');\n // All files with GCS prefix of 'test-folder' have been downloaded.\n\n### uploadFileInChunks(filePath, options, generator)\n\n uploadFileInChunks(filePath: string, options?: UploadFileInChunksOptions, generator?: MultiPartHelperGenerator): Promise\u003cGaxiosResponse | undefined\u003e;\n\nUpload a large file in chunks utilizing parallel upload opertions. If the upload fails, an uploadId and map containing all the successfully uploaded parts will be returned to the caller. These arguments can be used to resume the upload.\n\n**Example** \n\n\n const {Storage} = require('https://cloud.google.com/nodejs/docs/reference/storage/latest/overview.html');\n const storage = new Storage();\n const bucket = storage.bucket('my-bucket');\n const transferManager = new https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html(bucket);\n\n //-\n // Upload a large file in chunks utilizing parallel operations.\n //-\n const response = await transferManager.https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html('large-file.txt');\n // Your bucket now contains:\n // - \"large-file.txt\"\n\n### uploadManyFiles(filePathsOrDirectory, options)\n\n uploadManyFiles(filePathsOrDirectory: string[] | string, options?: UploadManyFilesOptions): Promise\u003cUploadResponse[]\u003e;\n\nUpload multiple files in parallel to the bucket. This is a convenience method that utilizes to perform the upload.\n\n**Example** \n\n\n const {Storage} = require('https://cloud.google.com/nodejs/docs/reference/storage/latest/overview.html');\n const storage = new Storage();\n const bucket = storage.bucket('my-bucket');\n const transferManager = new https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html(bucket);\n\n //-\n // Upload multiple files in parallel.\n //-\n const response = await transferManager.https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html(['/local/path/file1.txt, 'local/path/file2.txt']);\n // Your bucket now contains:\n // - \"local/path/file1.txt\" (with the contents of '/local/path/file1.txt')\n // - \"local/path/file2.txt\" (with the contents of '/local/path/file2.txt')\n const response = await transferManager.https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager.html('/local/directory');\n // Your bucket will now contain all files contained in '/local/directory' maintaining the subdirectory structure."]]