Parcourir la source

add getBucket metadata argument (#4770)

* add metadata to getBucket

* change getBucket call
Mikael Finstad il y a 1 an
Parent
commit
724bd7b3ed

+ 1 - 1
packages/@uppy/companion/src/server/Uploader.js

@@ -655,7 +655,7 @@ class Uploader {
     const { client, options } = s3Options
 
     const params = {
-      Bucket: getBucket(options.bucket),
+      Bucket: getBucket(options.bucket, null, this.options.metadata),
       Key: options.getKey(null, filename, this.options.metadata),
       ContentType: this.options.metadata.type,
       Metadata: rfc2047EncodeMetadata(this.options.metadata),

+ 2 - 2
packages/@uppy/companion/src/server/helpers/utils.js

@@ -187,8 +187,8 @@ module.exports.rfc2047EncodeMetadata = (metadata) => (
   Object.fromEntries(Object.entries(metadata).map((entry) => entry.map(rfc2047Encode)))
 )
 
-module.exports.getBucket = (bucketOrFn, req) => {
-  const bucket = typeof bucketOrFn === 'function' ? bucketOrFn(req) : bucketOrFn
+module.exports.getBucket = (bucketOrFn, req, metadata) => {
+  const bucket = typeof bucketOrFn === 'function' ? bucketOrFn(req, metadata) : bucketOrFn
 
   if (typeof bucket !== 'string' || bucket === '') {
     // This means a misconfiguration or bug