mirror of
https://github.com/remotely-save/remotely-save.git
synced 2024-06-07 21:10:45 +00:00
use multipart-upload
This commit is contained in:
parent
a7e6bed071
commit
6757348ac9
@ -35,6 +35,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.37.0",
|
||||
"@aws-sdk/lib-storage": "^3.40.1",
|
||||
"@aws-sdk/signature-v4-crt": "^3.37.0",
|
||||
"acorn": "^8.5.0",
|
||||
"aws-crt": "^1.10.1",
|
||||
|
19
src/s3.ts
19
src/s3.ts
@ -3,6 +3,7 @@ import { Readable } from "stream";
|
||||
|
||||
import { Vault } from "obsidian";
|
||||
|
||||
import { Upload } from "@aws-sdk/lib-storage";
|
||||
import {
|
||||
S3Client,
|
||||
ListObjectsV2Command,
|
||||
@ -115,14 +116,24 @@ export const uploadToRemote = async (
|
||||
remoteContent = await encryptArrayBuffer(localContent, password);
|
||||
}
|
||||
const body = arrayBufferToBuffer(remoteContent);
|
||||
await s3Client.send(
|
||||
new PutObjectCommand({
|
||||
|
||||
const upload = new Upload({
|
||||
client: s3Client,
|
||||
queueSize: 20, // concurrency
|
||||
partSize: 5242880, // minimal 5MB by default
|
||||
leavePartsOnError: false,
|
||||
params: {
|
||||
Bucket: s3Config.s3BucketName,
|
||||
Key: uploadFile,
|
||||
Body: body,
|
||||
ContentType: contentType,
|
||||
})
|
||||
);
|
||||
},
|
||||
});
|
||||
upload.on("httpUploadProgress", (progress) => {
|
||||
// console.log(progress);
|
||||
});
|
||||
await upload.done();
|
||||
|
||||
return await getRemoteMeta(s3Client, s3Config, uploadFile);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user