@aws-sdk/lib-storage 3.1068.0 → 3.1070.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/dist-cjs/index.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var runtimeConfig = require('./runtimeConfig');
|
|
9
|
-
var stream = require('stream');
|
|
1
|
+
const { PutObjectCommand, ChecksumAlgorithm, CreateMultipartUploadCommand, AbortMultipartUploadCommand, UploadPartCommand, CompleteMultipartUploadCommand, PutObjectTaggingCommand } = require("@aws-sdk/client-s3");
|
|
2
|
+
const { toEndpointV1, getEndpointFromInstructions } = require("@smithy/core/endpoints");
|
|
3
|
+
const { extendedEncodeURIComponent } = require("@smithy/core/protocols");
|
|
4
|
+
const { EventEmitter } = require("events");
|
|
5
|
+
const { Buffer } = require("buffer");
|
|
6
|
+
const { runtimeConfig } = require("./runtimeConfig");
|
|
7
|
+
const { Readable } = require("stream");
|
|
10
8
|
|
|
11
9
|
const byteLength = (input) => {
|
|
12
10
|
if (input == null) {
|
|
13
11
|
return 0;
|
|
14
12
|
}
|
|
15
13
|
if (typeof input === "string") {
|
|
16
|
-
return
|
|
14
|
+
return Buffer.byteLength(input);
|
|
17
15
|
}
|
|
18
16
|
if (typeof input.byteLength === "number") {
|
|
19
17
|
return input.byteLength;
|
|
@@ -27,9 +25,9 @@ const byteLength = (input) => {
|
|
|
27
25
|
else if (typeof input.start === "number" && typeof input.end === "number") {
|
|
28
26
|
return input.end + 1 - input.start;
|
|
29
27
|
}
|
|
30
|
-
else if (runtimeConfig.
|
|
28
|
+
else if (runtimeConfig.isFileReadStream(input)) {
|
|
31
29
|
try {
|
|
32
|
-
return runtimeConfig.
|
|
30
|
+
return runtimeConfig.lstatSync(input.path).size;
|
|
33
31
|
}
|
|
34
32
|
catch (error) {
|
|
35
33
|
return undefined;
|
|
@@ -71,9 +69,9 @@ const byteLengthSource = (input, override) => {
|
|
|
71
69
|
else if (typeof input.start === "number" && typeof input.end === "number") {
|
|
72
70
|
return BYTE_LENGTH_SOURCE.START_END_DIFF;
|
|
73
71
|
}
|
|
74
|
-
else if (runtimeConfig.
|
|
72
|
+
else if (runtimeConfig.isFileReadStream(input)) {
|
|
75
73
|
try {
|
|
76
|
-
runtimeConfig.
|
|
74
|
+
runtimeConfig.lstatSync(input.path).size;
|
|
77
75
|
return BYTE_LENGTH_SOURCE.LSTAT;
|
|
78
76
|
}
|
|
79
77
|
catch (error) {
|
|
@@ -90,7 +88,7 @@ async function* getChunkStream(data, partSize, getNextData) {
|
|
|
90
88
|
currentBuffer.chunks.push(datum);
|
|
91
89
|
currentBuffer.length += datum.byteLength;
|
|
92
90
|
while (currentBuffer.length > partSize) {
|
|
93
|
-
const dataChunk = currentBuffer.chunks.length > 1 ?
|
|
91
|
+
const dataChunk = currentBuffer.chunks.length > 1 ? Buffer.concat(currentBuffer.chunks) : currentBuffer.chunks[0];
|
|
94
92
|
yield {
|
|
95
93
|
partNumber,
|
|
96
94
|
data: dataChunk.subarray(0, partSize),
|
|
@@ -102,7 +100,7 @@ async function* getChunkStream(data, partSize, getNextData) {
|
|
|
102
100
|
}
|
|
103
101
|
yield {
|
|
104
102
|
partNumber,
|
|
105
|
-
data: currentBuffer.chunks.length !== 1 ?
|
|
103
|
+
data: currentBuffer.chunks.length !== 1 ? Buffer.concat(currentBuffer.chunks) : currentBuffer.chunks[0],
|
|
106
104
|
lastPart: true,
|
|
107
105
|
};
|
|
108
106
|
}
|
|
@@ -129,11 +127,11 @@ async function* getChunkUint8Array(data, partSize) {
|
|
|
129
127
|
|
|
130
128
|
async function* getDataReadable(data) {
|
|
131
129
|
for await (const chunk of data) {
|
|
132
|
-
if (
|
|
130
|
+
if (Buffer.isBuffer(chunk) || chunk instanceof Uint8Array) {
|
|
133
131
|
yield chunk;
|
|
134
132
|
}
|
|
135
133
|
else {
|
|
136
|
-
yield
|
|
134
|
+
yield Buffer.from(chunk);
|
|
137
135
|
}
|
|
138
136
|
}
|
|
139
137
|
}
|
|
@@ -146,11 +144,11 @@ async function* getDataReadableStream(data) {
|
|
|
146
144
|
if (done) {
|
|
147
145
|
return;
|
|
148
146
|
}
|
|
149
|
-
if (
|
|
147
|
+
if (Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
150
148
|
yield value;
|
|
151
149
|
}
|
|
152
150
|
else {
|
|
153
|
-
yield
|
|
151
|
+
yield Buffer.from(value);
|
|
154
152
|
}
|
|
155
153
|
}
|
|
156
154
|
}
|
|
@@ -166,11 +164,11 @@ const getChunk = (data, partSize) => {
|
|
|
166
164
|
if (data instanceof Uint8Array) {
|
|
167
165
|
return getChunkUint8Array(data, partSize);
|
|
168
166
|
}
|
|
169
|
-
if (data instanceof
|
|
167
|
+
if (data instanceof Readable) {
|
|
170
168
|
return getChunkStream(data, partSize, getDataReadable);
|
|
171
169
|
}
|
|
172
170
|
if (data instanceof String || typeof data === "string") {
|
|
173
|
-
return getChunkUint8Array(
|
|
171
|
+
return getChunkUint8Array(Buffer.from(data), partSize);
|
|
174
172
|
}
|
|
175
173
|
if (typeof data.stream === "function") {
|
|
176
174
|
return getChunkStream(data.stream(), partSize, getDataReadableStream);
|
|
@@ -181,7 +179,7 @@ const getChunk = (data, partSize) => {
|
|
|
181
179
|
throw new Error("Body Data is unsupported format, expected data to be one of: string | Uint8Array | Buffer | Readable | ReadableStream | Blob;.");
|
|
182
180
|
};
|
|
183
181
|
|
|
184
|
-
class Upload extends
|
|
182
|
+
class Upload extends EventEmitter {
|
|
185
183
|
static MIN_PART_SIZE = 1024 * 1024 * 5;
|
|
186
184
|
MAX_PARTS = 10_000;
|
|
187
185
|
queueSize = 4;
|
|
@@ -245,7 +243,7 @@ class Upload extends events.EventEmitter {
|
|
|
245
243
|
const params = { ...this.params, Body: dataPart.data };
|
|
246
244
|
const clientConfig = this.client.config;
|
|
247
245
|
const requestHandler = clientConfig.requestHandler;
|
|
248
|
-
const eventEmitter = requestHandler instanceof
|
|
246
|
+
const eventEmitter = requestHandler instanceof EventEmitter ? requestHandler : null;
|
|
249
247
|
const uploadEventListener = (event) => {
|
|
250
248
|
this.bytesUploadedSoFar = event.loaded;
|
|
251
249
|
this.totalBytes = event.total;
|
|
@@ -260,11 +258,11 @@ class Upload extends events.EventEmitter {
|
|
|
260
258
|
if (eventEmitter !== null) {
|
|
261
259
|
eventEmitter.on("xhr.upload.progress", uploadEventListener);
|
|
262
260
|
}
|
|
263
|
-
const resolved = await Promise.all([this.client.send(new
|
|
261
|
+
const resolved = await Promise.all([this.client.send(new PutObjectCommand(params)), clientConfig?.endpoint?.()]);
|
|
264
262
|
const putResult = resolved[0];
|
|
265
263
|
let endpoint = resolved[1];
|
|
266
264
|
if (!endpoint) {
|
|
267
|
-
endpoint =
|
|
265
|
+
endpoint = toEndpointV1(await getEndpointFromInstructions(params, PutObjectCommand, {
|
|
268
266
|
...clientConfig,
|
|
269
267
|
}));
|
|
270
268
|
}
|
|
@@ -276,9 +274,9 @@ class Upload extends events.EventEmitter {
|
|
|
276
274
|
}
|
|
277
275
|
const locationKey = this.params
|
|
278
276
|
.Key.split("/")
|
|
279
|
-
.map((segment) =>
|
|
277
|
+
.map((segment) => extendedEncodeURIComponent(segment))
|
|
280
278
|
.join("/");
|
|
281
|
-
const locationBucket =
|
|
279
|
+
const locationBucket = extendedEncodeURIComponent(this.params.Bucket);
|
|
282
280
|
const Location = (() => {
|
|
283
281
|
const endpointHostnameIncludesBucket = endpoint.hostname.startsWith(`${locationBucket}.`);
|
|
284
282
|
const forcePathStyle = this.client.config.forcePathStyle;
|
|
@@ -311,12 +309,12 @@ class Upload extends events.EventEmitter {
|
|
|
311
309
|
if (!this.createMultiPartPromise) {
|
|
312
310
|
const createCommandParams = { ...this.params, Body: undefined };
|
|
313
311
|
if (requestChecksumCalculation === "WHEN_SUPPORTED") {
|
|
314
|
-
createCommandParams.ChecksumAlgorithm = this.params.ChecksumAlgorithm ||
|
|
312
|
+
createCommandParams.ChecksumAlgorithm = this.params.ChecksumAlgorithm || ChecksumAlgorithm.CRC32;
|
|
315
313
|
}
|
|
316
314
|
this.createMultiPartPromise = this.client
|
|
317
|
-
.send(new
|
|
315
|
+
.send(new CreateMultipartUploadCommand(createCommandParams))
|
|
318
316
|
.then((createMpuResponse) => {
|
|
319
|
-
this.abortMultipartUploadCommand = new
|
|
317
|
+
this.abortMultipartUploadCommand = new AbortMultipartUploadCommand({
|
|
320
318
|
Bucket: this.params.Bucket,
|
|
321
319
|
Key: this.params.Key,
|
|
322
320
|
UploadId: createMpuResponse.UploadId,
|
|
@@ -346,7 +344,7 @@ class Upload extends events.EventEmitter {
|
|
|
346
344
|
}
|
|
347
345
|
const partSize = byteLength(dataPart.data) || 0;
|
|
348
346
|
const requestHandler = this.client.config.requestHandler;
|
|
349
|
-
const eventEmitter = requestHandler instanceof
|
|
347
|
+
const eventEmitter = requestHandler instanceof EventEmitter ? requestHandler : null;
|
|
350
348
|
let lastSeenBytes = 0;
|
|
351
349
|
const uploadEventListener = (event, request) => {
|
|
352
350
|
const requestPartSize = Number(request.query["partNumber"]) || -1;
|
|
@@ -370,7 +368,7 @@ class Upload extends events.EventEmitter {
|
|
|
370
368
|
}
|
|
371
369
|
this.uploadEnqueuedPartsCount += 1;
|
|
372
370
|
this.__validateUploadPart(dataPart);
|
|
373
|
-
const partResult = await this.client.send(new
|
|
371
|
+
const partResult = await this.client.send(new UploadPartCommand({
|
|
374
372
|
...this.params,
|
|
375
373
|
ContentLength: undefined,
|
|
376
374
|
UploadId: this.uploadId,
|
|
@@ -444,7 +442,7 @@ to input.params.ContentLength in bytes.
|
|
|
444
442
|
Parts: this.uploadedParts,
|
|
445
443
|
},
|
|
446
444
|
};
|
|
447
|
-
result = await this.client.send(new
|
|
445
|
+
result = await this.client.send(new CompleteMultipartUploadCommand(uploadCompleteParams));
|
|
448
446
|
if (typeof result?.Location === "string" && result.Location.includes("%2F")) {
|
|
449
447
|
result.Location = result.Location.replace(/%2F/g, "/");
|
|
450
448
|
}
|
|
@@ -454,7 +452,7 @@ to input.params.ContentLength in bytes.
|
|
|
454
452
|
}
|
|
455
453
|
this.abortMultipartUploadCommand = null;
|
|
456
454
|
if (this.tags.length) {
|
|
457
|
-
await this.client.send(new
|
|
455
|
+
await this.client.send(new PutObjectTaggingCommand({
|
|
458
456
|
...this.params,
|
|
459
457
|
Tagging: {
|
|
460
458
|
TagSet: this.tags,
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runtimeConfig = void 0;
|
|
4
|
-
const runtimeConfig_shared_1 = require("./runtimeConfig.shared");
|
|
1
|
+
const { runtimeConfigShared: shared } = require("./runtimeConfig.shared");
|
|
5
2
|
exports.runtimeConfig = {
|
|
6
|
-
...
|
|
3
|
+
...shared,
|
|
7
4
|
runtime: "browser",
|
|
8
5
|
};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.runtimeConfig = void 0;
|
|
4
|
-
const node_fs_1 = require("node:fs");
|
|
5
|
-
const runtimeConfig_shared_1 = require("./runtimeConfig.shared");
|
|
1
|
+
const { lstatSync, ReadStream } = require("node:fs");
|
|
2
|
+
const { runtimeConfigShared: shared } = require("./runtimeConfig.shared");
|
|
6
3
|
exports.runtimeConfig = {
|
|
7
|
-
...
|
|
4
|
+
...shared,
|
|
8
5
|
runtime: "node",
|
|
9
|
-
lstatSync
|
|
6
|
+
lstatSync,
|
|
10
7
|
isFileReadStream(f) {
|
|
11
|
-
return f instanceof
|
|
8
|
+
return f instanceof ReadStream;
|
|
12
9
|
},
|
|
13
10
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const runtimeConfig_browser_1 = require("./runtimeConfig.browser");
|
|
5
|
-
exports.runtimeConfig = {
|
|
6
|
-
...runtimeConfig_browser_1.runtimeConfig,
|
|
1
|
+
const { runtimeConfig: browserConfig } = require("./runtimeConfig.browser");
|
|
2
|
+
const runtimeConfig = {
|
|
3
|
+
...browserConfig,
|
|
7
4
|
runtime: "react-native",
|
|
8
5
|
};
|
|
6
|
+
exports.runtimeConfig = runtimeConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/lib-storage",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1070.0",
|
|
4
4
|
"description": "Storage higher order operation",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
10
10
|
"build:cjs": "node ../../scripts/compilation/inline",
|
|
11
|
-
"build:es": "tsc -p tsconfig.es.json",
|
|
11
|
+
"build:es": "premove dist-es && tsc -p tsconfig.es.json",
|
|
12
12
|
"build:include:deps": "yarn g:turbo run build -F=\"$npm_package_name\"",
|
|
13
|
-
"build:types": "tsc -p tsconfig.types.json",
|
|
13
|
+
"build:types": "premove dist-types && tsc -p tsconfig.types.json",
|
|
14
14
|
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
|
|
15
|
-
"clean": "premove dist-cjs dist-es dist-types
|
|
15
|
+
"clean": "premove dist-cjs dist-es dist-types",
|
|
16
16
|
"extract:docs": "api-extractor run --local",
|
|
17
17
|
"test": "yarn g:vitest run",
|
|
18
18
|
"test:watch": "yarn g:vitest watch",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"tslib": "^2.6.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@aws-sdk/client-s3": "^3.
|
|
41
|
+
"@aws-sdk/client-s3": "^3.1070.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@aws-sdk/client-s3": "3.
|
|
44
|
+
"@aws-sdk/client-s3": "3.1070.0",
|
|
45
45
|
"@tsconfig/recommended": "1.0.1",
|
|
46
46
|
"@types/node": "^20.14.8",
|
|
47
47
|
"concurrently": "7.0.0",
|