@@ -94,6 +94,10 @@ const GCCL_GCS_CMD_FEATURE = {
9494
9595export interface UploadManyFilesOptions {
9696 concurrencyLimit ?: number ;
97+ customDestinationBuilder ?(
98+ path : string ,
99+ options : UploadManyFilesOptions
100+ ) : string ;
97101 skipIfExists ?: boolean ;
98102 prefix ?: string ;
99103 passthroughOptions ?: Omit < UploadOptions , 'destination' > ;
@@ -411,6 +415,8 @@ export class TransferManager {
411415 * @typedef {object } UploadManyFilesOptions
412416 * @property {number } [concurrencyLimit] The number of concurrently executing promises
413417 * 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.
414420 * @property {boolean } [skipIfExists] Do not upload the file if it already exists in
415421 * the bucket. This will set the precondition ifGenerationMatch = 0.
416422 * @property {string } [prefix] A prefix to append to all of the uploaded files.
@@ -490,9 +496,9 @@ export class TransferManager {
490496 [ GCCL_GCS_CMD_KEY ] : GCCL_GCS_CMD_FEATURE . UPLOAD_MANY ,
491497 } ;
492498
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 ) ;
496502 if ( options . prefix ) {
497503 passThroughOptionsCopy . destination = path . posix . join (
498504 ...options . prefix . split ( path . sep ) ,
0 commit comments