@@ -33,31 +33,31 @@ const DEFAULT_PARALLEL_LARGE_FILE_DOWNLOAD_LIMIT = 2;
33
33
const LARGE_FILE_SIZE_THRESHOLD = 256 * 1024 * 1024 ;
34
34
const LARGE_FILE_DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024 ;
35
35
const EMPTY_REGEX = '(?:)' ;
36
- export interface UploadMultiOptions {
36
+ export interface UploadManyFilesOptions {
37
37
concurrencyLimit ?: number ;
38
38
skipIfExists ?: boolean ;
39
39
prefix ?: string ;
40
40
passthroughOptions ?: Omit < UploadOptions , 'destination' > ;
41
41
}
42
42
43
- export interface DownloadMultiOptions {
43
+ export interface DownloadManyFilesOptions {
44
44
concurrencyLimit ?: number ;
45
45
prefix ?: string ;
46
46
stripPrefix ?: string ;
47
47
passthroughOptions ?: DownloadOptions ;
48
48
}
49
49
50
- export interface LargeFileDownloadOptions {
50
+ export interface DownloadFileInChunksOptions {
51
51
concurrencyLimit ?: number ;
52
52
chunkSizeBytes ?: number ;
53
- path ?: string ;
53
+ destination ?: string ;
54
54
}
55
55
56
- export interface UploadMultiCallback {
56
+ export interface UploadManyFilesCallback {
57
57
( err : Error | null , files ?: File [ ] , metadata ?: Metadata [ ] ) : void ;
58
58
}
59
59
60
- export interface DownloadMultiCallback {
60
+ export interface DownloadManyFilesCallback {
61
61
( err : Error | null , contents ?: Buffer [ ] ) : void ;
62
62
}
63
63
@@ -76,21 +76,21 @@ export class TransferManager {
76
76
this . bucket = bucket ;
77
77
}
78
78
79
- async uploadMulti (
79
+ async uploadManyFiles (
80
80
filePaths : string [ ] ,
81
- options ?: UploadMultiOptions
81
+ options ?: UploadManyFilesOptions
82
82
) : Promise < UploadResponse [ ] > ;
83
- async uploadMulti (
83
+ async uploadManyFiles (
84
84
filePaths : string [ ] ,
85
- callback : UploadMultiCallback
85
+ callback : UploadManyFilesCallback
86
86
) : Promise < void > ;
87
- async uploadMulti (
87
+ async uploadManyFiles (
88
88
filePaths : string [ ] ,
89
- options : UploadMultiOptions ,
90
- callback : UploadMultiCallback
89
+ options : UploadManyFilesOptions ,
90
+ callback : UploadManyFilesCallback
91
91
) : Promise < void > ;
92
92
/**
93
- * @typedef {object } UploadMultiOptions
93
+ * @typedef {object } UploadManyFilesOptions
94
94
* @property {number } [concurrencyLimit] The number of concurrently executing promises
95
95
* to use when uploading the files.
96
96
* @property {boolean } [skipIfExists] Do not upload the file if it already exists in
@@ -101,7 +101,7 @@ export class TransferManager {
101
101
* @experimental
102
102
*/
103
103
/**
104
- * @callback UploadMultiCallback
104
+ * @callback UploadManyFilesCallback
105
105
* @param {?Error } [err] Request error, if any.
106
106
* @param {array } [files] Array of uploaded {@link File}.
107
107
* @param {array } [metadata] Array of uploaded {@link Metadata}
@@ -113,8 +113,8 @@ export class TransferManager {
113
113
*
114
114
* @param {array } [filePaths] An array of fully qualified paths to the files.
115
115
* to be uploaded to the bucket
116
- * @param {UploadMultiOptions } [options] Configuration options.
117
- * @param {UploadMultiCallback } [callback] Callback function.
116
+ * @param {UploadManyFilesOptions } [options] Configuration options.
117
+ * @param {UploadManyFilesCallback } [callback] Callback function.
118
118
* @returns {Promise<UploadResponse[] | void> }
119
119
*
120
120
* @example
@@ -127,7 +127,7 @@ export class TransferManager {
127
127
* //-
128
128
* // Upload multiple files in parallel.
129
129
* //-
130
- * transferManager.uploadMulti (['/local/path/file1.txt, 'local/path/file2.txt'], function(err, files, metadata) {
130
+ * transferManager.uploadManyFiles (['/local/path/file1.txt, 'local/path/file2.txt'], function(err, files, metadata) {
131
131
* // Your bucket now contains:
132
132
* // - "file1.txt" (with the contents of '/local/path/file1.txt')
133
133
* // - "file2.txt" (with the contents of '/local/path/file2.txt')
@@ -137,16 +137,16 @@ export class TransferManager {
137
137
* //-
138
138
* // If the callback is omitted, we will return a promise.
139
139
* //-
140
- * const response = await transferManager.uploadMulti (['/local/path/file1.txt, 'local/path/file2.txt']);
140
+ * const response = await transferManager.uploadManyFiles (['/local/path/file1.txt, 'local/path/file2.txt']);
141
141
* ```
142
142
* @experimental
143
143
*/
144
- async uploadMulti (
144
+ async uploadManyFiles (
145
145
filePaths : string [ ] ,
146
- optionsOrCallback ?: UploadMultiOptions | UploadMultiCallback ,
147
- callback ?: UploadMultiCallback
146
+ optionsOrCallback ?: UploadManyFilesOptions | UploadManyFilesCallback ,
147
+ callback ?: UploadManyFilesCallback
148
148
) : Promise < void | UploadResponse [ ] > {
149
- let options : UploadMultiOptions = { } ;
149
+ let options : UploadManyFilesOptions = { } ;
150
150
if ( typeof optionsOrCallback === 'function' ) {
151
151
callback = optionsOrCallback ;
152
152
} else if ( optionsOrCallback ) {
@@ -208,21 +208,21 @@ export class TransferManager {
208
208
return Promise . all ( promises ) ;
209
209
}
210
210
211
- async downloadMulti (
211
+ async downloadManyFiles (
212
212
files : File [ ] ,
213
- options ?: DownloadMultiOptions
213
+ options ?: DownloadManyFilesOptions
214
214
) : Promise < DownloadResponse [ ] > ;
215
- async downloadMulti (
215
+ async downloadManyFiles (
216
216
files : File [ ] ,
217
- callback : DownloadMultiCallback
217
+ callback : DownloadManyFilesCallback
218
218
) : Promise < void > ;
219
- async downloadMulti (
219
+ async downloadManyFiles (
220
220
files : File [ ] ,
221
- options : DownloadMultiOptions ,
222
- callback : DownloadMultiCallback
221
+ options : DownloadManyFilesOptions ,
222
+ callback : DownloadManyFilesCallback
223
223
) : Promise < void > ;
224
224
/**
225
- * @typedef {object } DownloadMultiOptions
225
+ * @typedef {object } DownloadManyFilesOptions
226
226
* @property {number } [concurrencyLimit] The number of concurrently executing promises
227
227
* to use when downloading the files.
228
228
* @property {string } [prefix] A prefix to append to all of the downloaded files.
@@ -232,7 +232,7 @@ export class TransferManager {
232
232
* @experimental
233
233
*/
234
234
/**
235
- * @callback DownloadMultiCallback
235
+ * @callback DownloadManyFilesCallback
236
236
* @param {?Error } [err] Request error, if any.
237
237
* @param {array } [contents] Contents of the downloaded files.
238
238
* @experimental
@@ -242,8 +242,8 @@ export class TransferManager {
242
242
* that utilizes {@link File#download} to perform the download.
243
243
*
244
244
* @param {array } [files] An array of file objects to be downloaded.
245
- * @param {DownloadMultiOptions } [options] Configuration options.
246
- * @param {DownloadMultiCallback } {callback } Callback function.
245
+ * @param {DownloadManyFilesOptions } [options] Configuration options.
246
+ * @param {DownloadManyFilesCallback } {callback } Callback function.
247
247
* @returns {Promise<DownloadResponse[] | void> }
248
248
*
249
249
* @example
@@ -256,7 +256,7 @@ export class TransferManager {
256
256
* //-
257
257
* // Download multiple files in parallel.
258
258
* //-
259
- * transferManager.downloadMulti ([bucket.file('file1.txt'), bucket.file('file2.txt')], function(err, contents){
259
+ * transferManager.downloadManyFiles ([bucket.file('file1.txt'), bucket.file('file2.txt')], function(err, contents){
260
260
* // Your local directory now contains:
261
261
* // - "file1.txt" (with the contents from my-bucket.file1.txt)
262
262
* // - "file2.txt" (with the contents from my-bucket.file2.txt)
@@ -266,15 +266,15 @@ export class TransferManager {
266
266
* //-
267
267
* // If the callback is omitted, we will return a promise.
268
268
* //-
269
- * const response = await transferManager.downloadMulti (bucket.File('file1.txt'), bucket.File('file2.txt')]);
269
+ * const response = await transferManager.downloadManyFiles (bucket.File('file1.txt'), bucket.File('file2.txt')]);
270
270
* @experimental
271
271
*/
272
- async downloadMulti (
272
+ async downloadManyFiles (
273
273
files : File [ ] ,
274
- optionsOrCallback ?: DownloadMultiOptions | DownloadMultiCallback ,
275
- callback ?: DownloadMultiCallback
274
+ optionsOrCallback ?: DownloadManyFilesOptions | DownloadManyFilesCallback ,
275
+ callback ?: DownloadManyFilesCallback
276
276
) : Promise < void | DownloadResponse [ ] > {
277
- let options : DownloadMultiOptions = { } ;
277
+ let options : DownloadManyFilesOptions = { } ;
278
278
if ( typeof optionsOrCallback === 'function' ) {
279
279
callback = optionsOrCallback ;
280
280
} else if ( optionsOrCallback ) {
@@ -323,21 +323,21 @@ export class TransferManager {
323
323
return Promise . all ( promises ) ;
324
324
}
325
325
326
- async downloadLargeFile (
326
+ async downloadFileInChunks (
327
327
file : File ,
328
- options ?: LargeFileDownloadOptions
328
+ options ?: DownloadFileInChunksOptions
329
329
) : Promise < DownloadResponse > ;
330
- async downloadLargeFile (
330
+ async downloadFileInChunks (
331
331
file : File ,
332
332
callback : DownloadCallback
333
333
) : Promise < void > ;
334
- async downloadLargeFile (
334
+ async downloadFileInChunks (
335
335
file : File ,
336
- options : LargeFileDownloadOptions ,
336
+ options : DownloadFileInChunksOptions ,
337
337
callback : DownloadCallback
338
338
) : Promise < void > ;
339
339
/**
340
- * @typedef {object } LargeFileDownloadOptions
340
+ * @typedef {object } DownloadFileInChunksOptions
341
341
* @property {number } [concurrencyLimit] The number of concurrently executing promises
342
342
* to use when downloading the file.
343
343
* @property {number } [chunkSizeBytes] The size in bytes of each chunk to be downloaded.
@@ -348,7 +348,7 @@ export class TransferManager {
348
348
* that utilizes {@link File#download} to perform the download.
349
349
*
350
350
* @param {object } [file] {@link File } to download.
351
- * @param {LargeFileDownloadOptions } [options] Configuration options.
351
+ * @param {DownloadFileInChunksOptions } [options] Configuration options.
352
352
* @param {DownloadCallback } [callbac] Callback function.
353
353
* @returns {Promise<DownloadResponse | void> }
354
354
*
@@ -373,12 +373,12 @@ export class TransferManager {
373
373
* const response = await transferManager.downloadLargeFile(bucket.file('large-file.txt');
374
374
* @experimental
375
375
*/
376
- async downloadLargeFile (
376
+ async downloadFileInChunks (
377
377
file : File ,
378
- optionsOrCallback ?: LargeFileDownloadOptions | DownloadCallback ,
378
+ optionsOrCallback ?: DownloadFileInChunksOptions | DownloadCallback ,
379
379
callback ?: DownloadCallback
380
380
) : Promise < void | DownloadResponse > {
381
- let options : LargeFileDownloadOptions = { } ;
381
+ let options : DownloadFileInChunksOptions = { } ;
382
382
if ( typeof optionsOrCallback === 'function' ) {
383
383
callback = optionsOrCallback ;
384
384
} else if ( optionsOrCallback ) {
@@ -400,10 +400,7 @@ export class TransferManager {
400
400
}
401
401
402
402
let start = 0 ;
403
- const filePath = path . join (
404
- options . path || __dirname ,
405
- path . basename ( file . name )
406
- ) ;
403
+ const filePath = options . destination || path . basename ( file . name ) ;
407
404
const fileToWrite = await fsp . open ( filePath , 'w+' ) ;
408
405
while ( start < size ) {
409
406
const chunkStart = start ;
0 commit comments