Skip to content

Commit

Permalink
feat(asset-server-plugin): Add S3 upload options in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-advantitge authored Feb 17, 2021
1 parent 63d08a2 commit fa4d1c0
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions packages/asset-server-plugin/src/s3-asset-storage-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ export interface S3Config {
* Using type `any` in order to avoid the need to include `aws-sdk` dependency in general.
*/
nativeS3Configuration?: any;
/**
* @description
* Configuration object passed directly to the AWS SDK.
* ManagedUpload.ManagedUploadOptions can be used after importing aws-sdk.
* Using type `any` in order to avoid the need to include `aws-sdk` dependency in general.
*/
nativeS3UploadConfiguration?: any;
}

/**
Expand Down Expand Up @@ -148,22 +155,28 @@ export class S3AssetStorageStrategy implements AssetStorageStrategy {

async writeFileFromBuffer(fileName: string, data: Buffer): Promise<string> {
const result = await this.s3
.upload({
Bucket: this.s3Config.bucket,
Key: fileName,
Body: data,
})
.upload(
{
Bucket: this.s3Config.bucket,
Key: fileName,
Body: data,
},
this.s3Config.nativeS3UploadConfiguration,
)
.promise();
return result.Key;
}

async writeFileFromStream(fileName: string, data: Stream): Promise<string> {
const result = await this.s3
.upload({
Bucket: this.s3Config.bucket,
Key: fileName,
Body: data,
})
.upload(
{
Bucket: this.s3Config.bucket,
Key: fileName,
Body: data,
},
this.s3Config.nativeS3UploadConfiguration,
)
.promise();
return result.Key;
}
Expand Down

0 comments on commit fa4d1c0

Please sign in to comment.