Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 13 additions & 8 deletions src/file-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<NodeJS.ReadableStream> {
Expand All @@ -391,14 +394,16 @@ class S3FileStore implements FileStore {
contentType: string,
rs: stream.Readable,
): Promise<void> {
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<FileInfo | null> {
Expand Down
Loading