@aws-sdk/lib-storage 3.32.0 → 3.36.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 +38 -0
- package/dist-cjs/Upload.js +179 -0
- package/dist-cjs/bytelength.js +29 -0
- package/dist-cjs/chunker.js +30 -0
- package/dist-cjs/chunks/getChunkBuffer.js +23 -0
- package/dist-cjs/chunks/getChunkStream.js +28 -0
- package/dist-cjs/chunks/getDataReadable.js +10 -0
- package/dist-cjs/chunks/getDataReadableStream.js +22 -0
- package/dist-cjs/index.js +5 -0
- package/dist-cjs/runtimeConfig.browser.js +8 -0
- package/dist-cjs/runtimeConfig.js +10 -0
- package/dist-cjs/runtimeConfig.native.js +8 -0
- package/dist-cjs/runtimeConfig.shared.js +6 -0
- package/dist-cjs/types.js +2 -0
- package/dist-es/Upload.js +261 -0
- package/dist-es/bytelength.js +25 -0
- package/dist-es/chunker.js +26 -0
- package/dist-es/chunks/getChunkBuffer.js +37 -0
- package/dist-es/chunks/getChunkStream.js +68 -0
- package/dist-es/chunks/getDataReadable.js +44 -0
- package/dist-es/chunks/getDataReadableStream.js +38 -0
- package/{dist/types/index.d.ts → dist-es/index.js} +0 -0
- package/dist-es/runtimeConfig.browser.js +3 -0
- package/dist-es/runtimeConfig.js +4 -0
- package/dist-es/runtimeConfig.native.js +3 -0
- package/dist-es/runtimeConfig.shared.js +3 -0
- package/{dist/types/runtimeConfig.browser.d.ts → dist-es/types.js} +0 -0
- package/{dist/types → dist-types}/Upload.d.ts +0 -0
- package/{dist/types → dist-types}/bytelength.d.ts +0 -0
- package/{dist/types → dist-types}/chunker.d.ts +0 -0
- package/{dist/types → dist-types}/chunks/getChunkBuffer.d.ts +0 -0
- package/{dist/types → dist-types}/chunks/getChunkStream.d.ts +0 -0
- package/{dist/types → dist-types}/chunks/getDataReadable.d.ts +0 -0
- package/{dist/types → dist-types}/chunks/getDataReadableStream.d.ts +0 -0
- package/dist-types/index.d.ts +2 -0
- package/dist-types/runtimeConfig.browser.d.ts +7 -0
- package/dist-types/runtimeConfig.d.ts +9 -0
- package/dist-types/runtimeConfig.native.d.ts +7 -0
- package/dist-types/runtimeConfig.shared.d.ts +6 -0
- package/{dist/types → dist-types}/ts3.4/Upload.d.ts +0 -0
- package/{dist/types → dist-types}/ts3.4/bytelength.d.ts +0 -0
- package/{dist/types → dist-types}/ts3.4/chunker.d.ts +0 -0
- package/{dist/types → dist-types}/ts3.4/chunks/getChunkBuffer.d.ts +0 -0
- package/{dist/types → dist-types}/ts3.4/chunks/getChunkStream.d.ts +0 -0
- package/{dist/types → dist-types}/ts3.4/chunks/getDataReadable.d.ts +0 -0
- package/{dist/types → dist-types}/ts3.4/chunks/getDataReadableStream.d.ts +0 -0
- package/{dist/types → dist-types}/ts3.4/index.d.ts +0 -0
- package/dist-types/ts3.4/runtimeConfig.browser.d.ts +7 -0
- package/dist-types/ts3.4/runtimeConfig.d.ts +9 -0
- package/dist-types/ts3.4/runtimeConfig.native.d.ts +7 -0
- package/dist-types/ts3.4/runtimeConfig.shared.d.ts +6 -0
- package/{dist/types → dist-types}/ts3.4/types.d.ts +0 -0
- package/{dist/types → dist-types}/types.d.ts +0 -0
- package/package.json +15 -10
- package/dist/cjs/Upload.js +0 -198
- package/dist/cjs/bytelength.js +0 -30
- package/dist/cjs/chunker.js +0 -33
- package/dist/cjs/chunks/getChunkBuffer.js +0 -24
- package/dist/cjs/chunks/getChunkStream.js +0 -34
- package/dist/cjs/chunks/getDataReadable.js +0 -11
- package/dist/cjs/chunks/getDataReadableStream.js +0 -28
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/runtimeConfig.browser.js +0 -12
- package/dist/cjs/runtimeConfig.js +0 -14
- package/dist/cjs/runtimeConfig.native.js +0 -12
- package/dist/cjs/runtimeConfig.shared.js +0 -10
- package/dist/cjs/types.js +0 -3
- package/dist/es/Upload.js +0 -278
- package/dist/es/bytelength.js +0 -26
- package/dist/es/chunker.js +0 -29
- package/dist/es/chunks/getChunkBuffer.js +0 -38
- package/dist/es/chunks/getChunkStream.js +0 -70
- package/dist/es/chunks/getDataReadable.js +0 -45
- package/dist/es/chunks/getDataReadableStream.js +0 -43
- package/dist/es/index.js +0 -3
- package/dist/es/runtimeConfig.browser.js +0 -7
- package/dist/es/runtimeConfig.js +0 -8
- package/dist/es/runtimeConfig.native.js +0 -7
- package/dist/es/runtimeConfig.shared.js +0 -7
- package/dist/es/types.js +0 -2
- package/dist/types/runtimeConfig.d.ts +0 -1
- package/dist/types/runtimeConfig.native.d.ts +0 -1
- package/dist/types/runtimeConfig.shared.d.ts +0 -1
- package/dist/types/ts3.4/runtimeConfig.browser.d.ts +0 -1
- package/dist/types/ts3.4/runtimeConfig.d.ts +0 -1
- package/dist/types/ts3.4/runtimeConfig.native.d.ts +0 -1
- package/dist/types/ts3.4/runtimeConfig.shared.d.ts +0 -1
- package/example-code/config.ts +0 -4
- package/example-code/file-upload.ts +0 -24
- package/example-code/upload-abort.ts +0 -48
- package/example-code/upload-string.ts +0 -22
- package/example-code/upload-unknown-length-browser.ts +0 -57
- package/example-code/upload-unknown-length.ts +0 -43
- package/jest.config.js +0 -5
- package/karma.conf.js +0 -28
- package/tsconfig.cjs.json +0 -19
- package/tsconfig.es.json +0 -19
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.36.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.35.0...v3.36.0) (2021-10-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* publish files in dist-* only ([#2873](https://github.com/aws/aws-sdk-js-v3/issues/2873)) ([53b4243](https://github.com/aws/aws-sdk-js-v3/commit/53b4243b066f25ff2412d5f0dea1036054b2df32))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.35.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.34.0...v3.35.0) (2021-10-04)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @aws-sdk/lib-storage
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [3.34.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.33.0...v3.34.0) (2021-09-24)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* **non-clients:** remove comments from transpiled JS files ([#2813](https://github.com/aws/aws-sdk-js-v3/issues/2813)) ([e6fc7f3](https://github.com/aws/aws-sdk-js-v3/commit/e6fc7f3e0fa74785590ac19e7ed143c916bb9b6e))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# [3.33.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.32.0...v3.33.0) (2021-09-21)
|
|
37
|
+
|
|
38
|
+
**Note:** Version bump only for package @aws-sdk/lib-storage
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
# [3.32.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.31.0...v3.32.0) (2021-09-17)
|
|
7
45
|
|
|
8
46
|
**Note:** Version bump only for package @aws-sdk/lib-storage
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Upload = void 0;
|
|
4
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
5
|
+
const events_1 = require("events");
|
|
6
|
+
const chunker_1 = require("./chunker");
|
|
7
|
+
const bytelength_1 = require("./bytelength");
|
|
8
|
+
const abort_controller_1 = require("@aws-sdk/abort-controller");
|
|
9
|
+
const MIN_PART_SIZE = 1024 * 1024 * 5;
|
|
10
|
+
class Upload extends events_1.EventEmitter {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super();
|
|
13
|
+
this.MAX_PARTS = 10000;
|
|
14
|
+
this.queueSize = 4;
|
|
15
|
+
this.partSize = MIN_PART_SIZE;
|
|
16
|
+
this.leavePartsOnError = false;
|
|
17
|
+
this.tags = [];
|
|
18
|
+
this.concurrentUploaders = [];
|
|
19
|
+
this.uploadedParts = [];
|
|
20
|
+
this.isMultiPart = true;
|
|
21
|
+
this.queueSize = options.queueSize || this.queueSize;
|
|
22
|
+
this.partSize = options.partSize || this.partSize;
|
|
23
|
+
this.leavePartsOnError = options.leavePartsOnError || this.leavePartsOnError;
|
|
24
|
+
this.tags = options.tags || this.tags;
|
|
25
|
+
this.client = options.client;
|
|
26
|
+
this.params = options.params;
|
|
27
|
+
this.__validateInput();
|
|
28
|
+
this.totalBytes = bytelength_1.byteLength(this.params.Body);
|
|
29
|
+
this.bytesUploadedSoFar = 0;
|
|
30
|
+
this.abortController = new abort_controller_1.AbortController();
|
|
31
|
+
}
|
|
32
|
+
async abort() {
|
|
33
|
+
this.abortController.abort();
|
|
34
|
+
}
|
|
35
|
+
async done() {
|
|
36
|
+
return await Promise.race([this.__doMultipartUpload(), this.__abortTimeout(this.abortController.signal)]);
|
|
37
|
+
}
|
|
38
|
+
on(event, listener) {
|
|
39
|
+
this.uploadEvent = event;
|
|
40
|
+
super.on(event, listener);
|
|
41
|
+
}
|
|
42
|
+
async __uploadUsingPut(dataPart) {
|
|
43
|
+
this.isMultiPart = false;
|
|
44
|
+
const params = { ...this.params, Body: dataPart.data };
|
|
45
|
+
const putResult = await this.client.send(new client_s3_1.PutObjectCommand(params));
|
|
46
|
+
this.putResponse = putResult;
|
|
47
|
+
const totalSize = bytelength_1.byteLength(dataPart.data);
|
|
48
|
+
this.__notifyProgress({
|
|
49
|
+
loaded: totalSize,
|
|
50
|
+
total: totalSize,
|
|
51
|
+
part: 1,
|
|
52
|
+
Key: this.params.Key,
|
|
53
|
+
Bucket: this.params.Bucket,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async __createMultipartUpload() {
|
|
57
|
+
if (!this.createMultiPartPromise) {
|
|
58
|
+
const createCommandParams = { ...this.params, Body: undefined };
|
|
59
|
+
this.createMultiPartPromise = this.client.send(new client_s3_1.CreateMultipartUploadCommand(createCommandParams));
|
|
60
|
+
}
|
|
61
|
+
const createMultipartUploadResult = await this.createMultiPartPromise;
|
|
62
|
+
this.uploadId = createMultipartUploadResult.UploadId;
|
|
63
|
+
}
|
|
64
|
+
async __doConcurrentUpload(dataFeeder) {
|
|
65
|
+
for await (const dataPart of dataFeeder) {
|
|
66
|
+
if (this.uploadedParts.length > this.MAX_PARTS) {
|
|
67
|
+
throw new Error(`Exceeded ${this.MAX_PARTS} as part of the upload to ${this.params.Key} and ${this.params.Bucket}.`);
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
if (this.abortController.signal.aborted) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (dataPart.partNumber === 1 && dataPart.lastPart) {
|
|
74
|
+
return await this.__uploadUsingPut(dataPart);
|
|
75
|
+
}
|
|
76
|
+
if (!this.uploadId) {
|
|
77
|
+
await this.__createMultipartUpload();
|
|
78
|
+
if (this.abortController.signal.aborted) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const partResult = await this.client.send(new client_s3_1.UploadPartCommand({
|
|
83
|
+
...this.params,
|
|
84
|
+
UploadId: this.uploadId,
|
|
85
|
+
Body: dataPart.data,
|
|
86
|
+
PartNumber: dataPart.partNumber,
|
|
87
|
+
}));
|
|
88
|
+
if (this.abortController.signal.aborted) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.uploadedParts.push({
|
|
92
|
+
PartNumber: dataPart.partNumber,
|
|
93
|
+
ETag: partResult.ETag,
|
|
94
|
+
});
|
|
95
|
+
this.bytesUploadedSoFar += bytelength_1.byteLength(dataPart.data);
|
|
96
|
+
this.__notifyProgress({
|
|
97
|
+
loaded: this.bytesUploadedSoFar,
|
|
98
|
+
total: this.totalBytes,
|
|
99
|
+
part: dataPart.partNumber,
|
|
100
|
+
Key: this.params.Key,
|
|
101
|
+
Bucket: this.params.Bucket,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
if (!this.uploadId) {
|
|
106
|
+
throw e;
|
|
107
|
+
}
|
|
108
|
+
if (this.leavePartsOnError) {
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async __doMultipartUpload() {
|
|
115
|
+
const dataFeeder = chunker_1.getChunk(this.params.Body, this.partSize);
|
|
116
|
+
for (let index = 0; index < this.queueSize; index++) {
|
|
117
|
+
const currentUpload = this.__doConcurrentUpload(dataFeeder);
|
|
118
|
+
this.concurrentUploaders.push(currentUpload);
|
|
119
|
+
}
|
|
120
|
+
await Promise.all(this.concurrentUploaders);
|
|
121
|
+
if (this.abortController.signal.aborted) {
|
|
122
|
+
throw Object.assign(new Error("Upload aborted."), { name: "AbortError" });
|
|
123
|
+
}
|
|
124
|
+
let result;
|
|
125
|
+
if (this.isMultiPart) {
|
|
126
|
+
this.uploadedParts.sort((a, b) => a.PartNumber - b.PartNumber);
|
|
127
|
+
const uploadCompleteParams = {
|
|
128
|
+
...this.params,
|
|
129
|
+
Body: undefined,
|
|
130
|
+
UploadId: this.uploadId,
|
|
131
|
+
MultipartUpload: {
|
|
132
|
+
Parts: this.uploadedParts,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
result = await this.client.send(new client_s3_1.CompleteMultipartUploadCommand(uploadCompleteParams));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
result = this.putResponse;
|
|
139
|
+
}
|
|
140
|
+
if (this.tags.length) {
|
|
141
|
+
await this.client.send(new client_s3_1.PutObjectTaggingCommand({
|
|
142
|
+
...this.params,
|
|
143
|
+
Tagging: {
|
|
144
|
+
TagSet: this.tags,
|
|
145
|
+
},
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
__notifyProgress(progress) {
|
|
151
|
+
if (this.uploadEvent) {
|
|
152
|
+
this.emit(this.uploadEvent, progress);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async __abortTimeout(abortSignal) {
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
abortSignal.onabort = () => {
|
|
158
|
+
const abortError = new Error("Upload aborted.");
|
|
159
|
+
abortError.name = "AbortError";
|
|
160
|
+
reject(abortError);
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
__validateInput() {
|
|
165
|
+
if (!this.params) {
|
|
166
|
+
throw new Error(`InputError: Upload requires params to be passed to upload.`);
|
|
167
|
+
}
|
|
168
|
+
if (!this.client) {
|
|
169
|
+
throw new Error(`InputError: Upload requires a AWS client to do uploads with.`);
|
|
170
|
+
}
|
|
171
|
+
if (this.partSize < MIN_PART_SIZE) {
|
|
172
|
+
throw new Error(`EntityTooSmall: Your proposed upload partsize [${this.partSize}] is smaller than the minimum allowed size [${MIN_PART_SIZE}] (5MB)`);
|
|
173
|
+
}
|
|
174
|
+
if (this.queueSize < 1) {
|
|
175
|
+
throw new Error(`Queue size: Must have at least one uploading queue.`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.Upload = Upload;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.byteLength = void 0;
|
|
4
|
+
const runtimeConfig_1 = require("./runtimeConfig");
|
|
5
|
+
const byteLength = (input) => {
|
|
6
|
+
if (input === null || input === undefined)
|
|
7
|
+
return 0;
|
|
8
|
+
if (typeof input === "string")
|
|
9
|
+
input = Buffer.from(input);
|
|
10
|
+
if (typeof input.byteLength === "number") {
|
|
11
|
+
return input.byteLength;
|
|
12
|
+
}
|
|
13
|
+
else if (typeof input.length === "number") {
|
|
14
|
+
return input.length;
|
|
15
|
+
}
|
|
16
|
+
else if (typeof input.size === "number") {
|
|
17
|
+
return input.size;
|
|
18
|
+
}
|
|
19
|
+
else if (typeof input.path === "string") {
|
|
20
|
+
try {
|
|
21
|
+
return runtimeConfig_1.ClientDefaultValues.lstatSync(input.path).size;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
};
|
|
29
|
+
exports.byteLength = byteLength;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChunk = void 0;
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
const buffer_1 = require("buffer");
|
|
6
|
+
const getChunkBuffer_1 = require("./chunks/getChunkBuffer");
|
|
7
|
+
const getChunkStream_1 = require("./chunks/getChunkStream");
|
|
8
|
+
const getDataReadableStream_1 = require("./chunks/getDataReadableStream");
|
|
9
|
+
const getDataReadable_1 = require("./chunks/getDataReadable");
|
|
10
|
+
const getChunk = (data, partSize) => {
|
|
11
|
+
if (data instanceof buffer_1.Buffer) {
|
|
12
|
+
return getChunkBuffer_1.getChunkBuffer(data, partSize);
|
|
13
|
+
}
|
|
14
|
+
else if (data instanceof stream_1.Readable) {
|
|
15
|
+
return getChunkStream_1.getChunkStream(data, partSize, getDataReadable_1.getDataReadable);
|
|
16
|
+
}
|
|
17
|
+
else if (data instanceof String || typeof data === "string" || data instanceof Uint8Array) {
|
|
18
|
+
return getChunkBuffer_1.getChunkBuffer(buffer_1.Buffer.from(data), partSize);
|
|
19
|
+
}
|
|
20
|
+
if (typeof data.stream === "function") {
|
|
21
|
+
return getChunkStream_1.getChunkStream(data.stream(), partSize, getDataReadableStream_1.getDataReadableStream);
|
|
22
|
+
}
|
|
23
|
+
else if (data instanceof ReadableStream) {
|
|
24
|
+
return getChunkStream_1.getChunkStream(data, partSize, getDataReadableStream_1.getDataReadableStream);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
throw new Error("Body Data is unsupported format, expected data to be one of: string | Uint8Array | Buffer | Readable | ReadableStream | Blob;.");
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.getChunk = getChunk;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChunkBuffer = void 0;
|
|
4
|
+
async function* getChunkBuffer(data, partSize) {
|
|
5
|
+
let partNumber = 1;
|
|
6
|
+
let startByte = 0;
|
|
7
|
+
let endByte = partSize;
|
|
8
|
+
while (endByte < data.byteLength) {
|
|
9
|
+
yield {
|
|
10
|
+
partNumber,
|
|
11
|
+
data: data.slice(startByte, endByte),
|
|
12
|
+
};
|
|
13
|
+
partNumber += 1;
|
|
14
|
+
startByte = endByte;
|
|
15
|
+
endByte = startByte + partSize;
|
|
16
|
+
}
|
|
17
|
+
yield {
|
|
18
|
+
partNumber,
|
|
19
|
+
data: data.slice(startByte),
|
|
20
|
+
lastPart: true,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.getChunkBuffer = getChunkBuffer;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChunkStream = void 0;
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
5
|
+
async function* getChunkStream(data, partSize, getNextData) {
|
|
6
|
+
let partNumber = 1;
|
|
7
|
+
const currentBuffer = { chunks: [], length: 0 };
|
|
8
|
+
for await (const datum of getNextData(data)) {
|
|
9
|
+
currentBuffer.chunks.push(datum);
|
|
10
|
+
currentBuffer.length += datum.length;
|
|
11
|
+
while (currentBuffer.length >= partSize) {
|
|
12
|
+
const dataChunk = currentBuffer.chunks.length > 1 ? buffer_1.Buffer.concat(currentBuffer.chunks) : currentBuffer.chunks[0];
|
|
13
|
+
yield {
|
|
14
|
+
partNumber,
|
|
15
|
+
data: dataChunk.slice(0, partSize),
|
|
16
|
+
};
|
|
17
|
+
currentBuffer.chunks = [dataChunk.slice(partSize)];
|
|
18
|
+
currentBuffer.length = currentBuffer.chunks[0].length;
|
|
19
|
+
partNumber += 1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
yield {
|
|
23
|
+
partNumber,
|
|
24
|
+
data: buffer_1.Buffer.concat(currentBuffer.chunks),
|
|
25
|
+
lastPart: true,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.getChunkStream = getChunkStream;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDataReadable = void 0;
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
5
|
+
async function* getDataReadable(data) {
|
|
6
|
+
for await (const chunk of data) {
|
|
7
|
+
yield buffer_1.Buffer.from(chunk);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.getDataReadable = getDataReadable;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDataReadableStream = void 0;
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
5
|
+
async function* getDataReadableStream(data) {
|
|
6
|
+
const reader = data.getReader();
|
|
7
|
+
try {
|
|
8
|
+
while (true) {
|
|
9
|
+
const { done, value } = await reader.read();
|
|
10
|
+
if (done)
|
|
11
|
+
return;
|
|
12
|
+
yield buffer_1.Buffer.from(value);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
reader.releaseLock();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.getDataReadableStream = getDataReadableStream;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientDefaultValues = void 0;
|
|
4
|
+
const runtimeConfig_shared_1 = require("./runtimeConfig.shared");
|
|
5
|
+
exports.ClientDefaultValues = {
|
|
6
|
+
...runtimeConfig_shared_1.ClientSharedValues,
|
|
7
|
+
runtime: "browser",
|
|
8
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientDefaultValues = void 0;
|
|
4
|
+
const runtimeConfig_shared_1 = require("./runtimeConfig.shared");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
exports.ClientDefaultValues = {
|
|
7
|
+
...runtimeConfig_shared_1.ClientSharedValues,
|
|
8
|
+
runtime: "node",
|
|
9
|
+
lstatSync: fs_1.lstatSync,
|
|
10
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientDefaultValues = void 0;
|
|
4
|
+
const runtimeConfig_browser_1 = require("./runtimeConfig.browser");
|
|
5
|
+
exports.ClientDefaultValues = {
|
|
6
|
+
...runtimeConfig_browser_1.ClientDefaultValues,
|
|
7
|
+
runtime: "react-native",
|
|
8
|
+
};
|