@@ -94,6 +94,10 @@ const GCCL_GCS_CMD_FEATURE = {
94
94
95
95
export interface UploadManyFilesOptions {
96
96
concurrencyLimit ?: number ;
97
+ customDestinationBuilder ?(
98
+ path : string ,
99
+ options : UploadManyFilesOptions
100
+ ) : string ;
97
101
skipIfExists ?: boolean ;
98
102
prefix ?: string ;
99
103
passthroughOptions ?: Omit < UploadOptions , 'destination' > ;
@@ -411,6 +415,8 @@ export class TransferManager {
411
415
* @typedef {object } UploadManyFilesOptions
412
416
* @property {number } [concurrencyLimit] The number of concurrently executing promises
413
417
* to use when uploading the files.
418
+ * @property {Function } [customDestinationBuilder] A fuction that will take the current path of a local file
419
+ * and return a string representing a custom path to be used to upload the file to GCS.
414
420
* @property {boolean } [skipIfExists] Do not upload the file if it already exists in
415
421
* the bucket. This will set the precondition ifGenerationMatch = 0.
416
422
* @property {string } [prefix] A prefix to append to all of the uploaded files.
@@ -490,9 +496,9 @@ export class TransferManager {
490
496
[ GCCL_GCS_CMD_KEY ] : GCCL_GCS_CMD_FEATURE . UPLOAD_MANY ,
491
497
} ;
492
498
493
- passThroughOptionsCopy . destination = filePath
494
- . split ( path . sep )
495
- . join ( path . posix . sep ) ;
499
+ passThroughOptionsCopy . destination = options . customDestinationBuilder
500
+ ? options . customDestinationBuilder ( filePath , options )
501
+ : filePath . split ( path . sep ) . join ( path . posix . sep ) ;
496
502
if ( options . prefix ) {
497
503
passThroughOptionsCopy . destination = path . posix . join (
498
504
...options . prefix . split ( path . sep ) ,
0 commit comments