Skip to content

Commit

Permalink
Fix things revealed by testing (incl. workaround)
Browse files Browse the repository at this point in the history
1.  One needs MetadataDirective: 'REPLACE' when using object copying to
update metadata.  2.  One currently needs the workaround described in
aws/aws-sdk-js-v3#1800 (comment)
until the bug in the s3 SDK v3 is fixed.
  • Loading branch information
joshuaauerbachwatson committed Dec 30, 2020
1 parent 2923768 commit 22ad840
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion awsprovider/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class S3RemoteFile implements RemoteFile {
setMetadata(meta: SettableFileMetadata): Promise<any> {
const CopySource = `${this.bucketName}/${this.name}`
const { cacheControl: CacheControl, contentType: ContentType } = meta
const cmd = new CopyObjectCommand({ CopySource, Bucket: this.bucketName, Key: this.name, CacheControl, ContentType })
const cmd = new CopyObjectCommand({ CopySource, Bucket: this.bucketName, Key: this.name, CacheControl, ContentType, MetadataDirective: 'REPLACE' })
return this.s3.send(cmd)
}

Expand Down Expand Up @@ -205,6 +205,12 @@ const provider: StorageProvider = {
},
getClient: (namespace: string, apiHost: string, web: boolean, credentials: Record<string, any>) => {
const s3 = new S3Client(credentials)
s3.middlewareStack.add(
(next) => async (args: any) => {
delete args.request.headers['content-type']
return next(args)
},
{step: 'build'})
let bucketName = computeBucketStorageName(apiHost, namespace)
let url: string
if (web) {
Expand Down

0 comments on commit 22ad840

Please sign in to comment.