diff --git a/package.json b/package.json index 08e889c..cc794c0 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "dependencies": { "@aws-sdk/client-s3": "^3.1013.0", "@aws-sdk/credential-provider-node": "^3.972.23", + "@aws-sdk/lib-storage": "^3.1013.0", "@azure/identity": "^4.13.1", "@azure/service-bus": "^7.9.5", "@azure/storage-blob": "^12.31.0", diff --git a/src/file-store.ts b/src/file-store.ts index 207edc2..bb7edfc 100644 --- a/src/file-store.ts +++ b/src/file-store.ts @@ -3,6 +3,7 @@ import * as os from "node:os"; import * as path from "node:path"; import * as stream from "node:stream"; import * as S3 from "@aws-sdk/client-s3"; +import { Upload } from "@aws-sdk/lib-storage"; import * as AzureIden from "@azure/identity"; import { defaultProvider } from "@aws-sdk/credential-provider-node"; import { BlobServiceClient, ContainerClient } from "@azure/storage-blob"; @@ -363,14 +364,16 @@ class S3FileStore implements FileStore { contentType: string, localFilepath: string, ) { - await this.client.send( - new S3.PutObjectCommand({ + const upload = new Upload({ + client: this.client, + params: { Bucket: this.bucket, Key: filepath, Body: fs.createReadStream(localFilepath), ContentType: contentType, - }), - ); + }, + }); + await upload.done(); } async getAsStream(filepath: string): Promise { @@ -391,14 +394,16 @@ class S3FileStore implements FileStore { contentType: string, rs: stream.Readable, ): Promise { - await this.client.send( - new S3.PutObjectCommand({ + const upload = new Upload({ + client: this.client, + params: { Bucket: this.bucket, Key: filepath, Body: rs, ContentType: contentType, - }), - ); + }, + }); + await upload.done(); } async getInfo(filepath: string): Promise {