@empiricalrun/r2-uploader 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/upload/stream.d.ts.map +1 -1
- package/dist/upload/stream.js +23 -27
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/upload/stream.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEzD,eAAO,MAAM,iBAAiB,GAAU,QAAQ,oBAAoB,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/upload/stream.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEzD,eAAO,MAAM,iBAAiB,GAAU,QAAQ,oBAAoB,qBA0GnE,CAAC"}
|
package/dist/upload/stream.js
CHANGED
|
@@ -42,34 +42,30 @@ const uploadFileStreams = async (config) => {
|
|
|
42
42
|
let partNumber = 1;
|
|
43
43
|
const parts = [];
|
|
44
44
|
for await (const chunk of fileStream) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
await (0, async_retry_1.default)(async () => {
|
|
55
|
-
const { ETag } = await S3.send(uploadPartCommand);
|
|
56
|
-
logger_1.logger.debug("upload part command sent successfully for file", file.fullPath);
|
|
57
|
-
parts.push({ ETag: ETag, PartNumber: partNumber });
|
|
58
|
-
partNumber++;
|
|
59
|
-
}, {
|
|
60
|
-
retries: 5,
|
|
61
|
-
factor: 3,
|
|
62
|
-
minTimeout: 1_000,
|
|
63
|
-
maxTimeout: 60_000,
|
|
64
|
-
randomize: true,
|
|
65
|
-
onRetry: (err, i) => {
|
|
66
|
-
logger_1.logger.debug("Upload part retry attempt:", i, ":", file.fullPath);
|
|
67
|
-
},
|
|
45
|
+
const currentPartNumber = partNumber;
|
|
46
|
+
const chunkBuffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
47
|
+
const { ETag } = await (0, async_retry_1.default)(async () => {
|
|
48
|
+
const uploadPartCommand = new client_s3_1.UploadPartCommand({
|
|
49
|
+
Bucket: config.bucket,
|
|
50
|
+
Key: fileKey,
|
|
51
|
+
PartNumber: currentPartNumber,
|
|
52
|
+
UploadId,
|
|
53
|
+
Body: chunkBuffer,
|
|
68
54
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
return await S3.send(uploadPartCommand);
|
|
56
|
+
}, {
|
|
57
|
+
retries: 5,
|
|
58
|
+
factor: 3,
|
|
59
|
+
minTimeout: 1_000,
|
|
60
|
+
maxTimeout: 60_000,
|
|
61
|
+
randomize: true,
|
|
62
|
+
onRetry: (err, i) => {
|
|
63
|
+
logger_1.logger.debug("Upload part retry attempt:", i, ":", file.fullPath);
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
logger_1.logger.debug("upload part command sent successfully for file", file.fullPath);
|
|
67
|
+
parts.push({ ETag: ETag, PartNumber: currentPartNumber });
|
|
68
|
+
partNumber++;
|
|
73
69
|
}
|
|
74
70
|
const completeMultipartUploadParams = {
|
|
75
71
|
Bucket: config.bucket,
|