@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.
Files changed (97) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist-cjs/Upload.js +179 -0
  3. package/dist-cjs/bytelength.js +29 -0
  4. package/dist-cjs/chunker.js +30 -0
  5. package/dist-cjs/chunks/getChunkBuffer.js +23 -0
  6. package/dist-cjs/chunks/getChunkStream.js +28 -0
  7. package/dist-cjs/chunks/getDataReadable.js +10 -0
  8. package/dist-cjs/chunks/getDataReadableStream.js +22 -0
  9. package/dist-cjs/index.js +5 -0
  10. package/dist-cjs/runtimeConfig.browser.js +8 -0
  11. package/dist-cjs/runtimeConfig.js +10 -0
  12. package/dist-cjs/runtimeConfig.native.js +8 -0
  13. package/dist-cjs/runtimeConfig.shared.js +6 -0
  14. package/dist-cjs/types.js +2 -0
  15. package/dist-es/Upload.js +261 -0
  16. package/dist-es/bytelength.js +25 -0
  17. package/dist-es/chunker.js +26 -0
  18. package/dist-es/chunks/getChunkBuffer.js +37 -0
  19. package/dist-es/chunks/getChunkStream.js +68 -0
  20. package/dist-es/chunks/getDataReadable.js +44 -0
  21. package/dist-es/chunks/getDataReadableStream.js +38 -0
  22. package/{dist/types/index.d.ts → dist-es/index.js} +0 -0
  23. package/dist-es/runtimeConfig.browser.js +3 -0
  24. package/dist-es/runtimeConfig.js +4 -0
  25. package/dist-es/runtimeConfig.native.js +3 -0
  26. package/dist-es/runtimeConfig.shared.js +3 -0
  27. package/{dist/types/runtimeConfig.browser.d.ts → dist-es/types.js} +0 -0
  28. package/{dist/types → dist-types}/Upload.d.ts +0 -0
  29. package/{dist/types → dist-types}/bytelength.d.ts +0 -0
  30. package/{dist/types → dist-types}/chunker.d.ts +0 -0
  31. package/{dist/types → dist-types}/chunks/getChunkBuffer.d.ts +0 -0
  32. package/{dist/types → dist-types}/chunks/getChunkStream.d.ts +0 -0
  33. package/{dist/types → dist-types}/chunks/getDataReadable.d.ts +0 -0
  34. package/{dist/types → dist-types}/chunks/getDataReadableStream.d.ts +0 -0
  35. package/dist-types/index.d.ts +2 -0
  36. package/dist-types/runtimeConfig.browser.d.ts +7 -0
  37. package/dist-types/runtimeConfig.d.ts +9 -0
  38. package/dist-types/runtimeConfig.native.d.ts +7 -0
  39. package/dist-types/runtimeConfig.shared.d.ts +6 -0
  40. package/{dist/types → dist-types}/ts3.4/Upload.d.ts +0 -0
  41. package/{dist/types → dist-types}/ts3.4/bytelength.d.ts +0 -0
  42. package/{dist/types → dist-types}/ts3.4/chunker.d.ts +0 -0
  43. package/{dist/types → dist-types}/ts3.4/chunks/getChunkBuffer.d.ts +0 -0
  44. package/{dist/types → dist-types}/ts3.4/chunks/getChunkStream.d.ts +0 -0
  45. package/{dist/types → dist-types}/ts3.4/chunks/getDataReadable.d.ts +0 -0
  46. package/{dist/types → dist-types}/ts3.4/chunks/getDataReadableStream.d.ts +0 -0
  47. package/{dist/types → dist-types}/ts3.4/index.d.ts +0 -0
  48. package/dist-types/ts3.4/runtimeConfig.browser.d.ts +7 -0
  49. package/dist-types/ts3.4/runtimeConfig.d.ts +9 -0
  50. package/dist-types/ts3.4/runtimeConfig.native.d.ts +7 -0
  51. package/dist-types/ts3.4/runtimeConfig.shared.d.ts +6 -0
  52. package/{dist/types → dist-types}/ts3.4/types.d.ts +0 -0
  53. package/{dist/types → dist-types}/types.d.ts +0 -0
  54. package/package.json +15 -10
  55. package/dist/cjs/Upload.js +0 -198
  56. package/dist/cjs/bytelength.js +0 -30
  57. package/dist/cjs/chunker.js +0 -33
  58. package/dist/cjs/chunks/getChunkBuffer.js +0 -24
  59. package/dist/cjs/chunks/getChunkStream.js +0 -34
  60. package/dist/cjs/chunks/getDataReadable.js +0 -11
  61. package/dist/cjs/chunks/getDataReadableStream.js +0 -28
  62. package/dist/cjs/index.js +0 -6
  63. package/dist/cjs/runtimeConfig.browser.js +0 -12
  64. package/dist/cjs/runtimeConfig.js +0 -14
  65. package/dist/cjs/runtimeConfig.native.js +0 -12
  66. package/dist/cjs/runtimeConfig.shared.js +0 -10
  67. package/dist/cjs/types.js +0 -3
  68. package/dist/es/Upload.js +0 -278
  69. package/dist/es/bytelength.js +0 -26
  70. package/dist/es/chunker.js +0 -29
  71. package/dist/es/chunks/getChunkBuffer.js +0 -38
  72. package/dist/es/chunks/getChunkStream.js +0 -70
  73. package/dist/es/chunks/getDataReadable.js +0 -45
  74. package/dist/es/chunks/getDataReadableStream.js +0 -43
  75. package/dist/es/index.js +0 -3
  76. package/dist/es/runtimeConfig.browser.js +0 -7
  77. package/dist/es/runtimeConfig.js +0 -8
  78. package/dist/es/runtimeConfig.native.js +0 -7
  79. package/dist/es/runtimeConfig.shared.js +0 -7
  80. package/dist/es/types.js +0 -2
  81. package/dist/types/runtimeConfig.d.ts +0 -1
  82. package/dist/types/runtimeConfig.native.d.ts +0 -1
  83. package/dist/types/runtimeConfig.shared.d.ts +0 -1
  84. package/dist/types/ts3.4/runtimeConfig.browser.d.ts +0 -1
  85. package/dist/types/ts3.4/runtimeConfig.d.ts +0 -1
  86. package/dist/types/ts3.4/runtimeConfig.native.d.ts +0 -1
  87. package/dist/types/ts3.4/runtimeConfig.shared.d.ts +0 -1
  88. package/example-code/config.ts +0 -4
  89. package/example-code/file-upload.ts +0 -24
  90. package/example-code/upload-abort.ts +0 -48
  91. package/example-code/upload-string.ts +0 -22
  92. package/example-code/upload-unknown-length-browser.ts +0 -57
  93. package/example-code/upload-unknown-length.ts +0 -43
  94. package/jest.config.js +0 -5
  95. package/karma.conf.js +0 -28
  96. package/tsconfig.cjs.json +0 -19
  97. package/tsconfig.es.json +0 -19
@@ -0,0 +1,261 @@
1
+ import { __assign, __asyncValues, __awaiter, __extends, __generator } from "tslib";
2
+ import { CompleteMultipartUploadCommand, CreateMultipartUploadCommand, PutObjectCommand, PutObjectTaggingCommand, UploadPartCommand, } from "@aws-sdk/client-s3";
3
+ import { EventEmitter } from "events";
4
+ import { getChunk } from "./chunker";
5
+ import { byteLength } from "./bytelength";
6
+ import { AbortController } from "@aws-sdk/abort-controller";
7
+ var MIN_PART_SIZE = 1024 * 1024 * 5;
8
+ var Upload = (function (_super) {
9
+ __extends(Upload, _super);
10
+ function Upload(options) {
11
+ var _this = _super.call(this) || this;
12
+ _this.MAX_PARTS = 10000;
13
+ _this.queueSize = 4;
14
+ _this.partSize = MIN_PART_SIZE;
15
+ _this.leavePartsOnError = false;
16
+ _this.tags = [];
17
+ _this.concurrentUploaders = [];
18
+ _this.uploadedParts = [];
19
+ _this.isMultiPart = true;
20
+ _this.queueSize = options.queueSize || _this.queueSize;
21
+ _this.partSize = options.partSize || _this.partSize;
22
+ _this.leavePartsOnError = options.leavePartsOnError || _this.leavePartsOnError;
23
+ _this.tags = options.tags || _this.tags;
24
+ _this.client = options.client;
25
+ _this.params = options.params;
26
+ _this.__validateInput();
27
+ _this.totalBytes = byteLength(_this.params.Body);
28
+ _this.bytesUploadedSoFar = 0;
29
+ _this.abortController = new AbortController();
30
+ return _this;
31
+ }
32
+ Upload.prototype.abort = function () {
33
+ return __awaiter(this, void 0, void 0, function () {
34
+ return __generator(this, function (_a) {
35
+ this.abortController.abort();
36
+ return [2];
37
+ });
38
+ });
39
+ };
40
+ Upload.prototype.done = function () {
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ return __generator(this, function (_a) {
43
+ switch (_a.label) {
44
+ case 0: return [4, Promise.race([this.__doMultipartUpload(), this.__abortTimeout(this.abortController.signal)])];
45
+ case 1: return [2, _a.sent()];
46
+ }
47
+ });
48
+ });
49
+ };
50
+ Upload.prototype.on = function (event, listener) {
51
+ this.uploadEvent = event;
52
+ _super.prototype.on.call(this, event, listener);
53
+ };
54
+ Upload.prototype.__uploadUsingPut = function (dataPart) {
55
+ return __awaiter(this, void 0, void 0, function () {
56
+ var params, putResult, totalSize;
57
+ return __generator(this, function (_a) {
58
+ switch (_a.label) {
59
+ case 0:
60
+ this.isMultiPart = false;
61
+ params = __assign(__assign({}, this.params), { Body: dataPart.data });
62
+ return [4, this.client.send(new PutObjectCommand(params))];
63
+ case 1:
64
+ putResult = _a.sent();
65
+ this.putResponse = putResult;
66
+ totalSize = byteLength(dataPart.data);
67
+ this.__notifyProgress({
68
+ loaded: totalSize,
69
+ total: totalSize,
70
+ part: 1,
71
+ Key: this.params.Key,
72
+ Bucket: this.params.Bucket,
73
+ });
74
+ return [2];
75
+ }
76
+ });
77
+ });
78
+ };
79
+ Upload.prototype.__createMultipartUpload = function () {
80
+ return __awaiter(this, void 0, void 0, function () {
81
+ var createCommandParams, createMultipartUploadResult;
82
+ return __generator(this, function (_a) {
83
+ switch (_a.label) {
84
+ case 0:
85
+ if (!this.createMultiPartPromise) {
86
+ createCommandParams = __assign(__assign({}, this.params), { Body: undefined });
87
+ this.createMultiPartPromise = this.client.send(new CreateMultipartUploadCommand(createCommandParams));
88
+ }
89
+ return [4, this.createMultiPartPromise];
90
+ case 1:
91
+ createMultipartUploadResult = _a.sent();
92
+ this.uploadId = createMultipartUploadResult.UploadId;
93
+ return [2];
94
+ }
95
+ });
96
+ });
97
+ };
98
+ Upload.prototype.__doConcurrentUpload = function (dataFeeder) {
99
+ var dataFeeder_1, dataFeeder_1_1;
100
+ var e_1, _a;
101
+ return __awaiter(this, void 0, void 0, function () {
102
+ var dataPart, partResult, e_2, e_1_1;
103
+ return __generator(this, function (_b) {
104
+ switch (_b.label) {
105
+ case 0:
106
+ _b.trys.push([0, 12, 13, 18]);
107
+ dataFeeder_1 = __asyncValues(dataFeeder);
108
+ _b.label = 1;
109
+ case 1: return [4, dataFeeder_1.next()];
110
+ case 2:
111
+ if (!(dataFeeder_1_1 = _b.sent(), !dataFeeder_1_1.done)) return [3, 11];
112
+ dataPart = dataFeeder_1_1.value;
113
+ if (this.uploadedParts.length > this.MAX_PARTS) {
114
+ throw new Error("Exceeded " + this.MAX_PARTS + " as part of the upload to " + this.params.Key + " and " + this.params.Bucket + ".");
115
+ }
116
+ _b.label = 3;
117
+ case 3:
118
+ _b.trys.push([3, 9, , 10]);
119
+ if (this.abortController.signal.aborted) {
120
+ return [2];
121
+ }
122
+ if (!(dataPart.partNumber === 1 && dataPart.lastPart)) return [3, 5];
123
+ return [4, this.__uploadUsingPut(dataPart)];
124
+ case 4: return [2, _b.sent()];
125
+ case 5:
126
+ if (!!this.uploadId) return [3, 7];
127
+ return [4, this.__createMultipartUpload()];
128
+ case 6:
129
+ _b.sent();
130
+ if (this.abortController.signal.aborted) {
131
+ return [2];
132
+ }
133
+ _b.label = 7;
134
+ case 7: return [4, this.client.send(new UploadPartCommand(__assign(__assign({}, this.params), { UploadId: this.uploadId, Body: dataPart.data, PartNumber: dataPart.partNumber })))];
135
+ case 8:
136
+ partResult = _b.sent();
137
+ if (this.abortController.signal.aborted) {
138
+ return [2];
139
+ }
140
+ this.uploadedParts.push({
141
+ PartNumber: dataPart.partNumber,
142
+ ETag: partResult.ETag,
143
+ });
144
+ this.bytesUploadedSoFar += byteLength(dataPart.data);
145
+ this.__notifyProgress({
146
+ loaded: this.bytesUploadedSoFar,
147
+ total: this.totalBytes,
148
+ part: dataPart.partNumber,
149
+ Key: this.params.Key,
150
+ Bucket: this.params.Bucket,
151
+ });
152
+ return [3, 10];
153
+ case 9:
154
+ e_2 = _b.sent();
155
+ if (!this.uploadId) {
156
+ throw e_2;
157
+ }
158
+ if (this.leavePartsOnError) {
159
+ throw e_2;
160
+ }
161
+ return [3, 10];
162
+ case 10: return [3, 1];
163
+ case 11: return [3, 18];
164
+ case 12:
165
+ e_1_1 = _b.sent();
166
+ e_1 = { error: e_1_1 };
167
+ return [3, 18];
168
+ case 13:
169
+ _b.trys.push([13, , 16, 17]);
170
+ if (!(dataFeeder_1_1 && !dataFeeder_1_1.done && (_a = dataFeeder_1.return))) return [3, 15];
171
+ return [4, _a.call(dataFeeder_1)];
172
+ case 14:
173
+ _b.sent();
174
+ _b.label = 15;
175
+ case 15: return [3, 17];
176
+ case 16:
177
+ if (e_1) throw e_1.error;
178
+ return [7];
179
+ case 17: return [7];
180
+ case 18: return [2];
181
+ }
182
+ });
183
+ });
184
+ };
185
+ Upload.prototype.__doMultipartUpload = function () {
186
+ return __awaiter(this, void 0, void 0, function () {
187
+ var dataFeeder, index, currentUpload, result, uploadCompleteParams;
188
+ return __generator(this, function (_a) {
189
+ switch (_a.label) {
190
+ case 0:
191
+ dataFeeder = getChunk(this.params.Body, this.partSize);
192
+ for (index = 0; index < this.queueSize; index++) {
193
+ currentUpload = this.__doConcurrentUpload(dataFeeder);
194
+ this.concurrentUploaders.push(currentUpload);
195
+ }
196
+ return [4, Promise.all(this.concurrentUploaders)];
197
+ case 1:
198
+ _a.sent();
199
+ if (this.abortController.signal.aborted) {
200
+ throw Object.assign(new Error("Upload aborted."), { name: "AbortError" });
201
+ }
202
+ if (!this.isMultiPart) return [3, 3];
203
+ this.uploadedParts.sort(function (a, b) { return a.PartNumber - b.PartNumber; });
204
+ uploadCompleteParams = __assign(__assign({}, this.params), { Body: undefined, UploadId: this.uploadId, MultipartUpload: {
205
+ Parts: this.uploadedParts,
206
+ } });
207
+ return [4, this.client.send(new CompleteMultipartUploadCommand(uploadCompleteParams))];
208
+ case 2:
209
+ result = _a.sent();
210
+ return [3, 4];
211
+ case 3:
212
+ result = this.putResponse;
213
+ _a.label = 4;
214
+ case 4:
215
+ if (!this.tags.length) return [3, 6];
216
+ return [4, this.client.send(new PutObjectTaggingCommand(__assign(__assign({}, this.params), { Tagging: {
217
+ TagSet: this.tags,
218
+ } })))];
219
+ case 5:
220
+ _a.sent();
221
+ _a.label = 6;
222
+ case 6: return [2, result];
223
+ }
224
+ });
225
+ });
226
+ };
227
+ Upload.prototype.__notifyProgress = function (progress) {
228
+ if (this.uploadEvent) {
229
+ this.emit(this.uploadEvent, progress);
230
+ }
231
+ };
232
+ Upload.prototype.__abortTimeout = function (abortSignal) {
233
+ return __awaiter(this, void 0, void 0, function () {
234
+ return __generator(this, function (_a) {
235
+ return [2, new Promise(function (resolve, reject) {
236
+ abortSignal.onabort = function () {
237
+ var abortError = new Error("Upload aborted.");
238
+ abortError.name = "AbortError";
239
+ reject(abortError);
240
+ };
241
+ })];
242
+ });
243
+ });
244
+ };
245
+ Upload.prototype.__validateInput = function () {
246
+ if (!this.params) {
247
+ throw new Error("InputError: Upload requires params to be passed to upload.");
248
+ }
249
+ if (!this.client) {
250
+ throw new Error("InputError: Upload requires a AWS client to do uploads with.");
251
+ }
252
+ if (this.partSize < MIN_PART_SIZE) {
253
+ throw new Error("EntityTooSmall: Your proposed upload partsize [" + this.partSize + "] is smaller than the minimum allowed size [" + MIN_PART_SIZE + "] (5MB)");
254
+ }
255
+ if (this.queueSize < 1) {
256
+ throw new Error("Queue size: Must have at least one uploading queue.");
257
+ }
258
+ };
259
+ return Upload;
260
+ }(EventEmitter));
261
+ export { Upload };
@@ -0,0 +1,25 @@
1
+ import { ClientDefaultValues } from "./runtimeConfig";
2
+ export var byteLength = function (input) {
3
+ if (input === null || input === undefined)
4
+ return 0;
5
+ if (typeof input === "string")
6
+ input = Buffer.from(input);
7
+ if (typeof input.byteLength === "number") {
8
+ return input.byteLength;
9
+ }
10
+ else if (typeof input.length === "number") {
11
+ return input.length;
12
+ }
13
+ else if (typeof input.size === "number") {
14
+ return input.size;
15
+ }
16
+ else if (typeof input.path === "string") {
17
+ try {
18
+ return ClientDefaultValues.lstatSync(input.path).size;
19
+ }
20
+ catch (error) {
21
+ return undefined;
22
+ }
23
+ }
24
+ return undefined;
25
+ };
@@ -0,0 +1,26 @@
1
+ import { Readable } from "stream";
2
+ import { Buffer } from "buffer";
3
+ import { getChunkBuffer } from "./chunks/getChunkBuffer";
4
+ import { getChunkStream } from "./chunks/getChunkStream";
5
+ import { getDataReadableStream } from "./chunks/getDataReadableStream";
6
+ import { getDataReadable } from "./chunks/getDataReadable";
7
+ export var getChunk = function (data, partSize) {
8
+ if (data instanceof Buffer) {
9
+ return getChunkBuffer(data, partSize);
10
+ }
11
+ else if (data instanceof Readable) {
12
+ return getChunkStream(data, partSize, getDataReadable);
13
+ }
14
+ else if (data instanceof String || typeof data === "string" || data instanceof Uint8Array) {
15
+ return getChunkBuffer(Buffer.from(data), partSize);
16
+ }
17
+ if (typeof data.stream === "function") {
18
+ return getChunkStream(data.stream(), partSize, getDataReadableStream);
19
+ }
20
+ else if (data instanceof ReadableStream) {
21
+ return getChunkStream(data, partSize, getDataReadableStream);
22
+ }
23
+ else {
24
+ throw new Error("Body Data is unsupported format, expected data to be one of: string | Uint8Array | Buffer | Readable | ReadableStream | Blob;.");
25
+ }
26
+ };
@@ -0,0 +1,37 @@
1
+ import { __asyncGenerator, __await, __generator } from "tslib";
2
+ export function getChunkBuffer(data, partSize) {
3
+ return __asyncGenerator(this, arguments, function getChunkBuffer_1() {
4
+ var partNumber, startByte, endByte;
5
+ return __generator(this, function (_a) {
6
+ switch (_a.label) {
7
+ case 0:
8
+ partNumber = 1;
9
+ startByte = 0;
10
+ endByte = partSize;
11
+ _a.label = 1;
12
+ case 1:
13
+ if (!(endByte < data.byteLength)) return [3, 4];
14
+ return [4, __await({
15
+ partNumber: partNumber,
16
+ data: data.slice(startByte, endByte),
17
+ })];
18
+ case 2: return [4, _a.sent()];
19
+ case 3:
20
+ _a.sent();
21
+ partNumber += 1;
22
+ startByte = endByte;
23
+ endByte = startByte + partSize;
24
+ return [3, 1];
25
+ case 4: return [4, __await({
26
+ partNumber: partNumber,
27
+ data: data.slice(startByte),
28
+ lastPart: true,
29
+ })];
30
+ case 5: return [4, _a.sent()];
31
+ case 6:
32
+ _a.sent();
33
+ return [2];
34
+ }
35
+ });
36
+ });
37
+ }
@@ -0,0 +1,68 @@
1
+ import { __asyncGenerator, __asyncValues, __await, __generator } from "tslib";
2
+ import { Buffer } from "buffer";
3
+ export function getChunkStream(data, partSize, getNextData) {
4
+ return __asyncGenerator(this, arguments, function getChunkStream_1() {
5
+ var partNumber, currentBuffer, _a, _b, datum, dataChunk, e_1_1;
6
+ var e_1, _c;
7
+ return __generator(this, function (_d) {
8
+ switch (_d.label) {
9
+ case 0:
10
+ partNumber = 1;
11
+ currentBuffer = { chunks: [], length: 0 };
12
+ _d.label = 1;
13
+ case 1:
14
+ _d.trys.push([1, 9, 10, 15]);
15
+ _a = __asyncValues(getNextData(data));
16
+ _d.label = 2;
17
+ case 2: return [4, __await(_a.next())];
18
+ case 3:
19
+ if (!(_b = _d.sent(), !_b.done)) return [3, 8];
20
+ datum = _b.value;
21
+ currentBuffer.chunks.push(datum);
22
+ currentBuffer.length += datum.length;
23
+ _d.label = 4;
24
+ case 4:
25
+ if (!(currentBuffer.length >= partSize)) return [3, 7];
26
+ dataChunk = currentBuffer.chunks.length > 1 ? Buffer.concat(currentBuffer.chunks) : currentBuffer.chunks[0];
27
+ return [4, __await({
28
+ partNumber: partNumber,
29
+ data: dataChunk.slice(0, partSize),
30
+ })];
31
+ case 5: return [4, _d.sent()];
32
+ case 6:
33
+ _d.sent();
34
+ currentBuffer.chunks = [dataChunk.slice(partSize)];
35
+ currentBuffer.length = currentBuffer.chunks[0].length;
36
+ partNumber += 1;
37
+ return [3, 4];
38
+ case 7: return [3, 2];
39
+ case 8: return [3, 15];
40
+ case 9:
41
+ e_1_1 = _d.sent();
42
+ e_1 = { error: e_1_1 };
43
+ return [3, 15];
44
+ case 10:
45
+ _d.trys.push([10, , 13, 14]);
46
+ if (!(_b && !_b.done && (_c = _a.return))) return [3, 12];
47
+ return [4, __await(_c.call(_a))];
48
+ case 11:
49
+ _d.sent();
50
+ _d.label = 12;
51
+ case 12: return [3, 14];
52
+ case 13:
53
+ if (e_1) throw e_1.error;
54
+ return [7];
55
+ case 14: return [7];
56
+ case 15: return [4, __await({
57
+ partNumber: partNumber,
58
+ data: Buffer.concat(currentBuffer.chunks),
59
+ lastPart: true,
60
+ })];
61
+ case 16: return [4, _d.sent()];
62
+ case 17:
63
+ _d.sent();
64
+ return [2];
65
+ }
66
+ });
67
+ });
68
+ }
@@ -0,0 +1,44 @@
1
+ import { __asyncGenerator, __asyncValues, __await, __generator } from "tslib";
2
+ import { Buffer } from "buffer";
3
+ export function getDataReadable(data) {
4
+ return __asyncGenerator(this, arguments, function getDataReadable_1() {
5
+ var data_1, data_1_1, chunk, e_1_1;
6
+ var e_1, _a;
7
+ return __generator(this, function (_b) {
8
+ switch (_b.label) {
9
+ case 0:
10
+ _b.trys.push([0, 7, 8, 13]);
11
+ data_1 = __asyncValues(data);
12
+ _b.label = 1;
13
+ case 1: return [4, __await(data_1.next())];
14
+ case 2:
15
+ if (!(data_1_1 = _b.sent(), !data_1_1.done)) return [3, 6];
16
+ chunk = data_1_1.value;
17
+ return [4, __await(Buffer.from(chunk))];
18
+ case 3: return [4, _b.sent()];
19
+ case 4:
20
+ _b.sent();
21
+ _b.label = 5;
22
+ case 5: return [3, 1];
23
+ case 6: return [3, 13];
24
+ case 7:
25
+ e_1_1 = _b.sent();
26
+ e_1 = { error: e_1_1 };
27
+ return [3, 13];
28
+ case 8:
29
+ _b.trys.push([8, , 11, 12]);
30
+ if (!(data_1_1 && !data_1_1.done && (_a = data_1.return))) return [3, 10];
31
+ return [4, __await(_a.call(data_1))];
32
+ case 9:
33
+ _b.sent();
34
+ _b.label = 10;
35
+ case 10: return [3, 12];
36
+ case 11:
37
+ if (e_1) throw e_1.error;
38
+ return [7];
39
+ case 12: return [7];
40
+ case 13: return [2];
41
+ }
42
+ });
43
+ });
44
+ }
@@ -0,0 +1,38 @@
1
+ import { __asyncGenerator, __await, __generator } from "tslib";
2
+ import { Buffer } from "buffer";
3
+ export function getDataReadableStream(data) {
4
+ return __asyncGenerator(this, arguments, function getDataReadableStream_1() {
5
+ var reader, _a, done, value, e_1;
6
+ return __generator(this, function (_b) {
7
+ switch (_b.label) {
8
+ case 0:
9
+ reader = data.getReader();
10
+ _b.label = 1;
11
+ case 1:
12
+ _b.trys.push([1, 9, 10, 11]);
13
+ _b.label = 2;
14
+ case 2:
15
+ if (!true) return [3, 8];
16
+ return [4, __await(reader.read())];
17
+ case 3:
18
+ _a = _b.sent(), done = _a.done, value = _a.value;
19
+ if (!done) return [3, 5];
20
+ return [4, __await(void 0)];
21
+ case 4: return [2, _b.sent()];
22
+ case 5: return [4, __await(Buffer.from(value))];
23
+ case 6: return [4, _b.sent()];
24
+ case 7:
25
+ _b.sent();
26
+ return [3, 2];
27
+ case 8: return [3, 11];
28
+ case 9:
29
+ e_1 = _b.sent();
30
+ throw e_1;
31
+ case 10:
32
+ reader.releaseLock();
33
+ return [7];
34
+ case 11: return [2];
35
+ }
36
+ });
37
+ });
38
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ import { __assign } from "tslib";
2
+ import { ClientSharedValues } from "./runtimeConfig.shared";
3
+ export var ClientDefaultValues = __assign(__assign({}, ClientSharedValues), { runtime: "browser" });
@@ -0,0 +1,4 @@
1
+ import { __assign } from "tslib";
2
+ import { ClientSharedValues } from "./runtimeConfig.shared";
3
+ import { lstatSync } from "fs";
4
+ export var ClientDefaultValues = __assign(__assign({}, ClientSharedValues), { runtime: "node", lstatSync: lstatSync });
@@ -0,0 +1,3 @@
1
+ import { __assign } from "tslib";
2
+ import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser";
3
+ export var ClientDefaultValues = __assign(__assign({}, BrowserDefaults), { runtime: "react-native" });
@@ -0,0 +1,3 @@
1
+ export var ClientSharedValues = {
2
+ lstatSync: function () { },
3
+ };
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ export * from "./Upload";
2
+ export * from "./types";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare const ClientDefaultValues: {
5
+ runtime: string;
6
+ lstatSync: () => void;
7
+ };
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ import { lstatSync } from "fs";
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare const ClientDefaultValues: {
7
+ runtime: string;
8
+ lstatSync: typeof lstatSync;
9
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare const ClientDefaultValues: {
5
+ runtime: string;
6
+ lstatSync: () => void;
7
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare const ClientSharedValues: {
5
+ lstatSync: () => void;
6
+ };
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare const ClientDefaultValues: {
5
+ runtime: string;
6
+ lstatSync: () => void;
7
+ };
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ import { lstatSync } from "fs";
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare const ClientDefaultValues: {
7
+ runtime: string;
8
+ lstatSync: typeof lstatSync;
9
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare const ClientDefaultValues: {
5
+ runtime: string;
6
+ lstatSync: () => void;
7
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare const ClientSharedValues: {
5
+ lstatSync: () => void;
6
+ };
File without changes
File without changes