add getBucket metadata argument (#4770)

* add metadata to getBucket

* change getBucket call
This commit is contained in:
Mikael Finstad 2023-11-02 20:22:06 +09:00 committed by GitHub
parent 0854f12392
commit 724bd7b3ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -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),

View file

@ -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