Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit ad6aadd

Browse files
committed
add jsdoc comments to remaining functions
1 parent b2df5bd commit ad6aadd

1 file changed

Lines changed: 87 additions & 12 deletions

File tree

src/transfer-manager.ts

Lines changed: 87 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,11 @@ export class TransferManager {
9797
* @property {object} [passthroughOptions] {@link UploadOptions} Options to be passed through
9898
* to each individual upload operation.
9999
*/
100-
/**
101-
* @typedef {array} UploadResponse
102-
* @property {object} The uploaded {@link File}
103-
* @property {object} The uploaded {@link Metadata}
104-
*/
105100
/**
106101
* @callback UploadMultiCallback
107-
* @param {?Error} err Rewuest error if any
108-
* @param {array} files Array of uploaded {@link File}.
109-
* @param {array} metadata Array of uploaded {@link Metadata}
102+
* @param {?Error} [err] Request error, if any.
103+
* @param {array} [files] Array of uploaded {@link File}.
104+
* @param {array} [metadata] Array of uploaded {@link Metadata}
110105
*/
111106
/**
112107
* Upload multiple files in parallel to the bucket. This is a convenience method
@@ -126,19 +121,19 @@ export class TransferManager {
126121
* const transferManager = new TransferManager(bucket);
127122
*
128123
* //-
129-
* // Upload multiple files.
124+
* // Upload multiple files in parallel.
130125
* //-
131126
* transferManager.uploadMulti(['/local/path/file1.txt, 'local/path/file2.txt'], function(err, files, metadata) {
132-
* // Your bucket now contains:
127+
* // Your bucket now contains:
133128
* // - "file1.txt" (with the contents of '/local/path/file1.txt')
134129
* // - "file2.txt" (with the contents of '/local/path/file2.txt')
135130
* // `files` is an array of instances of File objects that refers to the new files.
136131
* });
137132
*
138133
* //-
139-
* // If the callback if omitted, we will return a Promise.
134+
* // If the callback is omitted, we will return a promise.
140135
* //-
141-
* const response = transferManager.uploadMulti(['/local/path/file1.txt, 'local/path/file2.txt']);
136+
* const response = await transferManager.uploadMulti(['/local/path/file1.txt, 'local/path/file2.txt']);
142137
* ```
143138
*/
144139
async uploadMulti(
@@ -217,6 +212,51 @@ export class TransferManager {
217212
options: DownloadMultiOptions,
218213
callback: DownloadMultiCallback
219214
): Promise<void>;
215+
/**
216+
* @typedef {object} DownloadMultiOptions
217+
* @property {number} [concurrencyLimit] The number of concurrently executing promises
218+
* to use when downloading the files.
219+
* @property {string} [prefix] A prefix to append to all of the downloaded files.
220+
* @property {string} [stripPrefix] A prefix to remove from all of the downloaded files.
221+
* @property {object} [passthroughOptions] {@link DownloadOptions} Options to be passed through
222+
* to each individual download operation.
223+
*/
224+
/**
225+
* @callback DownloadMultiCallback
226+
* @param {?Error} [err] Request error, if any.
227+
* @param {array} [contents] Contents of the downloaded files.
228+
*/
229+
/**
230+
* Download multiple files in parallel to the local filesystem. This is a convenience method
231+
* that utilizes {@link File#download} to perform the download.
232+
*
233+
* @param {array} [files] An array of file objects you wish to download.
234+
* @param {DownloadMultiOptions} [options] Configuration options.
235+
* @param {DownloadMultiCallback} {callback} Callback function.
236+
* @returns {Promise<DownloadResponse[] | void>}
237+
*
238+
* @example
239+
* ```
240+
* const {Storage} = require('@google-cloud/storage');
241+
* const storage = new Storage();
242+
* const bucket = storage.bucket('my-bucket');
243+
* const transferManager = new TransferManager(bucket);
244+
*
245+
* //-
246+
* // Download multiple files in parallel.
247+
* //-
248+
* transferManager.downloadMulti([bucket.file('file1.txt'), bucket.file('file2.txt')], function(err, contents){
249+
* // Your local directory now contains:
250+
* // - "file1.txt" (with the contents from my-bucket.file1.txt)
251+
* // - "file2.txt" (with the contents from my-bucket.file2.txt)
252+
* // `contents` is an array containing the file data for each downloaded file.
253+
* });
254+
*
255+
* //-
256+
* // If the callback is omitted, we will return a promise.
257+
* //-
258+
* const response = await transferManager.downloadMulti(bucket.File('file1.txt'), bucket.File('file2.txt')]);
259+
*/
220260
async downloadMulti(
221261
files: File[],
222262
optionsOrCallback?: DownloadMultiOptions | DownloadMultiCallback,
@@ -284,6 +324,41 @@ export class TransferManager {
284324
options: LargeFileDownloadOptions,
285325
callback: DownloadCallback
286326
): Promise<void>;
327+
/**
328+
* @typedef {object} LargeFileDownloadOptions
329+
* @property {number} [concurrencyLimit] The number of concurrently executing promises
330+
* to use when downloading the file.
331+
* @property {number} [chunkSizeBytes] The size in bytes of each chunk to be downloaded.
332+
*/
333+
/**
334+
* Download a large file in chunks utilizing parallel download operations. This is a convenience method
335+
* that utilizes {@link File#download} to perform the download.
336+
*
337+
* @param {object} [file] {@link File} to download.
338+
* @param {LargeFileDownloadOptions} [options] Configuration options.
339+
* @param {DownloadCallback} [callbac] Callback function.
340+
* @returns {Promise<DownloadResponse | void>}
341+
*
342+
* @example
343+
* ```
344+
* const {Storage} = require('@google-cloud/storage');
345+
* const storage = new Storage();
346+
* const bucket = storage.bucket('my-bucket');
347+
* const transferManager = new TransferManager(bucket);
348+
*
349+
* //-
350+
* // Download a large file in chunks utilizing parallel operations.
351+
* //-
352+
* transferManager.downloadLargeFile(bucket.file('large-file.txt'), function(err, contents) {
353+
* // Your local directory now contains:
354+
* // - "large-file.txt" (with the contents from my-bucket.large-file.txt)
355+
* });
356+
*
357+
* //-
358+
* // If the callback is omitted, we will return a promise.
359+
* //-
360+
* const response = await transferManager.downloadLargeFile(bucket.file('large-file.txt');
361+
*/
287362
async downloadLargeFile(
288363
file: File,
289364
optionsOrCallback?: LargeFileDownloadOptions | DownloadCallback,

0 commit comments

Comments
 (0)