@@ -21,7 +21,7 @@ import (
2121
2222var errUnsupportedOperation = errors .New ("Unsupported operation" )
2323
24- func Run (ctx context.Context , src , dst string , recursive bool , maxJobs uint , fsys afero.Fs ) error {
24+ func Run (ctx context.Context , src , dst string , recursive bool , maxJobs uint , fsys afero.Fs , opts ... func ( * client. FileOptions ) ) error {
2525 srcParsed , err := url .Parse (src )
2626 if err != nil {
2727 return errors .Errorf ("failed to parse src url: %w" , err )
@@ -41,9 +41,9 @@ func Run(ctx context.Context, src, dst string, recursive bool, maxJobs uint, fsy
4141 return client .DownloadStorageObject (ctx , projectRef , srcParsed .Path , dst , fsys )
4242 } else if srcParsed .Scheme == "" && strings .ToLower (dstParsed .Scheme ) == storage .STORAGE_SCHEME {
4343 if recursive {
44- return UploadStorageObjectAll (ctx , projectRef , dstParsed .Path , src , maxJobs , fsys )
44+ return UploadStorageObjectAll (ctx , projectRef , dstParsed .Path , src , maxJobs , fsys , opts ... )
4545 }
46- return client .UploadStorageObject (ctx , projectRef , dstParsed .Path , src , fsys )
46+ return client .UploadStorageObject (ctx , projectRef , dstParsed .Path , src , fsys , opts ... )
4747 } else if strings .ToLower (srcParsed .Scheme ) == storage .STORAGE_SCHEME && strings .ToLower (dstParsed .Scheme ) == storage .STORAGE_SCHEME {
4848 return errors .New ("Copying between buckets is not supported" )
4949 }
@@ -81,7 +81,7 @@ func DownloadStorageObjectAll(ctx context.Context, projectRef, remotePath, local
8181 return errors .Join (err , jq .Collect ())
8282}
8383
84- func UploadStorageObjectAll (ctx context.Context , projectRef , remotePath , localPath string , maxJobs uint , fsys afero.Fs ) error {
84+ func UploadStorageObjectAll (ctx context.Context , projectRef , remotePath , localPath string , maxJobs uint , fsys afero.Fs , opts ... func ( * client. FileOptions ) ) error {
8585 noSlash := strings .TrimSuffix (remotePath , "/" )
8686 // Check if directory exists on remote
8787 dirExists := false
@@ -125,14 +125,14 @@ func UploadStorageObjectAll(ctx context.Context, projectRef, remotePath, localPa
125125 }
126126 fmt .Fprintln (os .Stderr , "Uploading:" , filePath , "=>" , dstPath )
127127 job := func () error {
128- err := client .UploadStorageObject (ctx , projectRef , dstPath , filePath , fsys )
128+ err := client .UploadStorageObject (ctx , projectRef , dstPath , filePath , fsys , opts ... )
129129 if err != nil && strings .Contains (err .Error (), `"error":"Bucket not found"` ) {
130130 // Retry after creating bucket
131131 if bucket , prefix := storage .SplitBucketPrefix (dstPath ); len (prefix ) > 0 {
132132 if _ , err := client .CreateStorageBucket (ctx , projectRef , bucket ); err != nil {
133133 return err
134134 }
135- err = client .UploadStorageObject (ctx , projectRef , dstPath , filePath , fsys )
135+ err = client .UploadStorageObject (ctx , projectRef , dstPath , filePath , fsys , opts ... )
136136 }
137137 }
138138 return err
0 commit comments