@qrvey/object-storage 2.0.2-1167 → 2.0.3-beta
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/README.md +1 -1
- package/dist/cjs/index.js +1051 -163
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +45 -19
- package/dist/esm/index.mjs +1088 -158
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +45 -19
- package/package.json +10 -22
- package/dist/cjs/index-v2.js +0 -1717
- package/dist/cjs/index-v2.js.map +0 -1
- package/dist/esm/chunk-66BQA4WX.mjs +0 -96
- package/dist/esm/chunk-66BQA4WX.mjs.map +0 -1
- package/dist/esm/index-v2.d.mts +0 -417
- package/dist/esm/index-v2.mjs +0 -1600
- package/dist/esm/index-v2.mjs.map +0 -1
- package/dist/types/index-v2.d.ts +0 -417
package/dist/cjs/index.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var stream2 = require('stream');
|
|
4
4
|
var storageBlob = require('@azure/storage-blob');
|
|
5
5
|
var clientS3 = require('@aws-sdk/client-s3');
|
|
6
6
|
var credentialProviderNode = require('@aws-sdk/credential-provider-node');
|
|
7
7
|
var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
|
|
8
8
|
var libStorage = require('@aws-sdk/lib-storage');
|
|
9
|
-
var
|
|
9
|
+
var http = require('http');
|
|
10
|
+
var https = require('https');
|
|
11
|
+
var basicFtp = require('basic-ftp');
|
|
10
12
|
|
|
11
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
14
|
|
|
13
|
-
var
|
|
15
|
+
var stream2__default = /*#__PURE__*/_interopDefault(stream2);
|
|
14
16
|
|
|
15
17
|
var __defProp = Object.defineProperty;
|
|
16
18
|
var __defProps = Object.defineProperties;
|
|
@@ -36,7 +38,13 @@ var __spreadValues = (a, b) => {
|
|
|
36
38
|
return a;
|
|
37
39
|
};
|
|
38
40
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
39
|
-
var
|
|
41
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
42
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
43
|
+
}) : x)(function(x) {
|
|
44
|
+
if (typeof require !== "undefined")
|
|
45
|
+
return require.apply(this, arguments);
|
|
46
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
47
|
+
});
|
|
40
48
|
var __objRest = (source, exclude) => {
|
|
41
49
|
var target = {};
|
|
42
50
|
for (var prop in source)
|
|
@@ -49,10 +57,6 @@ var __objRest = (source, exclude) => {
|
|
|
49
57
|
}
|
|
50
58
|
return target;
|
|
51
59
|
};
|
|
52
|
-
var __publicField = (obj, key, value) => {
|
|
53
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
54
|
-
return value;
|
|
55
|
-
};
|
|
56
60
|
var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
|
|
57
61
|
|
|
58
62
|
// src/shared/utils/errorHandler.ts
|
|
@@ -80,7 +84,7 @@ var errorMessages = {
|
|
|
80
84
|
ObjectNotFound: "ObjectNotFound - The specified key does not exist. (404)",
|
|
81
85
|
DEFAULT: "An unknown error occurred"
|
|
82
86
|
};
|
|
83
|
-
var
|
|
87
|
+
var ErrorHandler = class {
|
|
84
88
|
static handleError(errorCode, errorMessage, errorObj) {
|
|
85
89
|
const errorResponse = {
|
|
86
90
|
code: errorCode,
|
|
@@ -95,8 +99,6 @@ var _ErrorHandler = class _ErrorHandler {
|
|
|
95
99
|
return errorResponse;
|
|
96
100
|
}
|
|
97
101
|
};
|
|
98
|
-
__name(_ErrorHandler, "ErrorHandler");
|
|
99
|
-
var ErrorHandler = _ErrorHandler;
|
|
100
102
|
|
|
101
103
|
// src/services/storage/blob/blobHelpers.ts
|
|
102
104
|
function BlobPropertiesResponseToObjectResponse(blobProperties) {
|
|
@@ -112,12 +114,11 @@ function BlobPropertiesResponseToObjectResponse(blobProperties) {
|
|
|
112
114
|
contentLanguage: blobProperties.contentLanguage
|
|
113
115
|
};
|
|
114
116
|
}
|
|
115
|
-
__name(BlobPropertiesResponseToObjectResponse, "BlobPropertiesResponseToObjectResponse");
|
|
116
117
|
|
|
117
118
|
// src/services/storage/blob/blocIdStorage.ts
|
|
118
|
-
var
|
|
119
|
+
var BlockIdStorage = class _BlockIdStorage {
|
|
119
120
|
constructor() {
|
|
120
|
-
|
|
121
|
+
this.blockIdMap = {};
|
|
121
122
|
}
|
|
122
123
|
static getInstance() {
|
|
123
124
|
if (!_BlockIdStorage.instance) {
|
|
@@ -138,30 +139,21 @@ var _BlockIdStorage = class _BlockIdStorage {
|
|
|
138
139
|
delete this.blockIdMap[blobName];
|
|
139
140
|
}
|
|
140
141
|
};
|
|
141
|
-
__name(_BlockIdStorage, "BlockIdStorage");
|
|
142
|
-
__publicField(_BlockIdStorage, "instance");
|
|
143
|
-
var BlockIdStorage = _BlockIdStorage;
|
|
144
142
|
|
|
145
143
|
// src/services/storage/blob/blobStorage.service.ts
|
|
146
|
-
var
|
|
144
|
+
var BlobStorageService = class {
|
|
147
145
|
/**
|
|
148
146
|
* Retrieves the properties of a blob from the container by its name.
|
|
149
147
|
*
|
|
150
148
|
* @param {string} blobName - The name of the blob.
|
|
149
|
+
* @param {ObjectStorageOptions} options - The options for the object storage service.
|
|
151
150
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
|
|
152
151
|
*/
|
|
153
|
-
constructor(containerName) {
|
|
154
|
-
__publicField(this, "blobServiceClient");
|
|
155
|
-
__publicField(this, "containerName");
|
|
152
|
+
constructor(containerName, options) {
|
|
156
153
|
this.containerName = containerName;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
if (!connectionString) {
|
|
162
|
-
connectionString = process.env.AZURE_STORAGE_CONNECTION_STRING;
|
|
163
|
-
}
|
|
164
|
-
this.blobServiceClient = storageBlob.BlobServiceClient.fromConnectionString(connectionString);
|
|
154
|
+
this.blobServiceClient = storageBlob.BlobServiceClient.fromConnectionString(
|
|
155
|
+
(options == null ? void 0 : options.connectionString) || process.env.AZURE_STORAGE_CONNECTION_STRING
|
|
156
|
+
);
|
|
165
157
|
}
|
|
166
158
|
/**
|
|
167
159
|
* Creates a writable stream for uploading a file to the Blob storage.
|
|
@@ -170,16 +162,15 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
170
162
|
* @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded blob, the writable stream, and a promise that resolves when the upload is complete.
|
|
171
163
|
*/
|
|
172
164
|
createUploadWriteStream(blobName) {
|
|
173
|
-
const streamPassThrough = new
|
|
174
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
165
|
+
const streamPassThrough = new stream2__default.default.PassThrough();
|
|
166
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
167
|
+
this.containerName
|
|
168
|
+
);
|
|
175
169
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
176
170
|
const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
|
|
177
171
|
onProgress: (ev) => console.log(ev)
|
|
178
172
|
}).then(() => {
|
|
179
|
-
return {
|
|
180
|
-
Bucket: this.containerName,
|
|
181
|
-
Key: blobName
|
|
182
|
-
};
|
|
173
|
+
return { Bucket: this.containerName, Key: blobName };
|
|
183
174
|
});
|
|
184
175
|
return {
|
|
185
176
|
key: blobName,
|
|
@@ -195,7 +186,9 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
195
186
|
*/
|
|
196
187
|
async getHeadObject(blobName) {
|
|
197
188
|
try {
|
|
198
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
189
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
190
|
+
this.containerName
|
|
191
|
+
);
|
|
199
192
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
200
193
|
const blobProperties = await blockBlobClient.getProperties();
|
|
201
194
|
return BlobPropertiesResponseToObjectResponse(blobProperties);
|
|
@@ -214,13 +207,18 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
214
207
|
var _a;
|
|
215
208
|
try {
|
|
216
209
|
let downloadBlockBlobResponse;
|
|
217
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
210
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
211
|
+
this.containerName
|
|
212
|
+
);
|
|
218
213
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
219
214
|
const expression = (options == null ? void 0 : options.range) || "";
|
|
220
215
|
const matches = expression.match(/\d+/g);
|
|
221
216
|
if (expression && (matches == null ? void 0 : matches.length)) {
|
|
222
217
|
const [start, end] = matches.map(Number);
|
|
223
|
-
downloadBlockBlobResponse = await blockBlobClient.download(
|
|
218
|
+
downloadBlockBlobResponse = await blockBlobClient.download(
|
|
219
|
+
start,
|
|
220
|
+
end
|
|
221
|
+
);
|
|
224
222
|
} else {
|
|
225
223
|
downloadBlockBlobResponse = await blockBlobClient.download(0);
|
|
226
224
|
}
|
|
@@ -240,7 +238,9 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
240
238
|
}
|
|
241
239
|
async getSignatureUrl(blobName, expiresInMinutes, permissions) {
|
|
242
240
|
try {
|
|
243
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
241
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
242
|
+
this.containerName
|
|
243
|
+
);
|
|
244
244
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
245
245
|
const startDate = /* @__PURE__ */ new Date();
|
|
246
246
|
const expiryDate = new Date(startDate);
|
|
@@ -256,11 +256,12 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
256
256
|
}
|
|
257
257
|
async getUploadUrl(blobName, expiresInMinutes) {
|
|
258
258
|
try {
|
|
259
|
-
const sasUrl = await this.getSignatureUrl(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
259
|
+
const sasUrl = await this.getSignatureUrl(
|
|
260
|
+
blobName,
|
|
261
|
+
expiresInMinutes,
|
|
262
|
+
"w"
|
|
263
|
+
);
|
|
264
|
+
return { key: blobName, signedUrl: sasUrl };
|
|
264
265
|
} catch (error) {
|
|
265
266
|
throw ErrorHandler.handleError("DEFAULT", "", error);
|
|
266
267
|
}
|
|
@@ -274,7 +275,11 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
274
275
|
*/
|
|
275
276
|
async getDownloadUrl(blobName, expiresInMinutes) {
|
|
276
277
|
try {
|
|
277
|
-
const sasUrl = await this.getSignatureUrl(
|
|
278
|
+
const sasUrl = await this.getSignatureUrl(
|
|
279
|
+
blobName,
|
|
280
|
+
expiresInMinutes,
|
|
281
|
+
"r"
|
|
282
|
+
);
|
|
278
283
|
return sasUrl;
|
|
279
284
|
} catch (error) {
|
|
280
285
|
throw ErrorHandler.handleError("DEFAULT", "", error);
|
|
@@ -290,16 +295,17 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
290
295
|
*/
|
|
291
296
|
async upload(blobName, body, metadata = {}) {
|
|
292
297
|
try {
|
|
293
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
298
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
299
|
+
this.containerName
|
|
300
|
+
);
|
|
294
301
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
295
|
-
Buffer.isBuffer(body) ? await blockBlobClient.upload(body, body.length, {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
};
|
|
302
|
+
Buffer.isBuffer(body) ? await blockBlobClient.upload(body, body.length, { metadata }) : await blockBlobClient.uploadStream(
|
|
303
|
+
body,
|
|
304
|
+
void 0,
|
|
305
|
+
void 0,
|
|
306
|
+
{ metadata }
|
|
307
|
+
);
|
|
308
|
+
return { key: blobName };
|
|
303
309
|
} catch (error) {
|
|
304
310
|
throw ErrorHandler.handleError("DEFAULT", "", error);
|
|
305
311
|
}
|
|
@@ -312,7 +318,9 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
312
318
|
*/
|
|
313
319
|
async delete(data) {
|
|
314
320
|
try {
|
|
315
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
321
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
322
|
+
this.containerName
|
|
323
|
+
);
|
|
316
324
|
return this.deleteObject(containerClient, data);
|
|
317
325
|
} catch (error) {
|
|
318
326
|
throw ErrorHandler.handleError("DEFAULT", "", error);
|
|
@@ -354,9 +362,16 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
354
362
|
let continuationToken = options.pagination;
|
|
355
363
|
const limit = (_a = options.limit) != null ? _a : 1e3;
|
|
356
364
|
let continueListing = true;
|
|
357
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
365
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
366
|
+
this.containerName
|
|
367
|
+
);
|
|
358
368
|
while (continueListing) {
|
|
359
|
-
const response = await this.listChunk(
|
|
369
|
+
const response = await this.listChunk(
|
|
370
|
+
options,
|
|
371
|
+
continuationToken,
|
|
372
|
+
limit - responseContents.length,
|
|
373
|
+
containerClient
|
|
374
|
+
);
|
|
360
375
|
continuationToken = response.continuationToken;
|
|
361
376
|
responseContents = responseContents.concat(response.items);
|
|
362
377
|
if (responseContents.length >= limit || !continuationToken) {
|
|
@@ -405,16 +420,10 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
405
420
|
pagination
|
|
406
421
|
}));
|
|
407
422
|
if ((_a = response.items) == null ? void 0 : _a.length)
|
|
408
|
-
allItems = [
|
|
409
|
-
...allItems,
|
|
410
|
-
...response.items
|
|
411
|
-
];
|
|
423
|
+
allItems = [...allItems, ...response.items];
|
|
412
424
|
pagination = (_b = response.pagination) != null ? _b : void 0;
|
|
413
425
|
} while (pagination);
|
|
414
|
-
return {
|
|
415
|
-
items: allItems,
|
|
416
|
-
count: allItems.length
|
|
417
|
-
};
|
|
426
|
+
return { items: allItems, count: allItems.length };
|
|
418
427
|
}
|
|
419
428
|
/**
|
|
420
429
|
* Deletes a blob from the blob storage service.
|
|
@@ -438,15 +447,14 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
438
447
|
* @return {Promise<{ key: string; deleted: boolean; error?: string }[]>} - A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each blob deleted.
|
|
439
448
|
*/
|
|
440
449
|
async deleteObjects(blobNames) {
|
|
441
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
450
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
451
|
+
this.containerName
|
|
452
|
+
);
|
|
442
453
|
const deleteBlobPromises = blobNames.map(async (blobName) => {
|
|
443
454
|
var _a;
|
|
444
455
|
try {
|
|
445
456
|
await this.deleteObject(containerClient, blobName);
|
|
446
|
-
return {
|
|
447
|
-
key: blobName,
|
|
448
|
-
deleted: true
|
|
449
|
-
};
|
|
457
|
+
return { key: blobName, deleted: true };
|
|
450
458
|
} catch (error) {
|
|
451
459
|
return {
|
|
452
460
|
key: blobName,
|
|
@@ -464,15 +472,21 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
464
472
|
*/
|
|
465
473
|
async getHeadBucket() {
|
|
466
474
|
try {
|
|
467
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
475
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
476
|
+
this.containerName
|
|
477
|
+
);
|
|
468
478
|
const properties = await containerClient.getProperties();
|
|
469
479
|
return properties;
|
|
470
480
|
} catch (error) {
|
|
471
|
-
throw new Error(
|
|
481
|
+
throw new Error(
|
|
482
|
+
"Error in Azure getHeadContainer. Container: " + this.containerName + " Error: " + error
|
|
483
|
+
);
|
|
472
484
|
}
|
|
473
485
|
}
|
|
474
486
|
async listMultipartUploadsForBucket() {
|
|
475
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
487
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
488
|
+
this.containerName
|
|
489
|
+
);
|
|
476
490
|
const blobList = containerClient.listBlobsFlat();
|
|
477
491
|
const uploads = [];
|
|
478
492
|
try {
|
|
@@ -507,12 +521,15 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
507
521
|
*/
|
|
508
522
|
async listMultipartUploadsForKey(blobName) {
|
|
509
523
|
var _a;
|
|
510
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
524
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
525
|
+
this.containerName
|
|
526
|
+
);
|
|
511
527
|
const blobClient = containerClient.getBlockBlobClient(blobName);
|
|
512
528
|
const listResponse = await blobClient.getBlockList("all");
|
|
513
529
|
const parts = ((_a = listResponse == null ? void 0 : listResponse.uncommittedBlocks) == null ? void 0 : _a.map((block, index) => ({
|
|
514
530
|
PartNumber: index + 1,
|
|
515
531
|
LastModified: /* @__PURE__ */ new Date(),
|
|
532
|
+
// Azure Blob Storage doesn't provide the last modified date for individual parts
|
|
516
533
|
ETag: block.name,
|
|
517
534
|
Size: block.size
|
|
518
535
|
}))) || [];
|
|
@@ -541,7 +558,9 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
541
558
|
* @return {Promise<string>} A Promise that resolves to a string representing the base64 encoded block ID of the uploaded part.
|
|
542
559
|
*/
|
|
543
560
|
async uploadMultipart(blobName, file, partNumber, uploadId) {
|
|
544
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
561
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
562
|
+
this.containerName
|
|
563
|
+
);
|
|
545
564
|
const blobClient = containerClient.getBlockBlobClient(blobName);
|
|
546
565
|
const blockIdBase = uploadId || await this.generateUploadIdMultipart();
|
|
547
566
|
const partId = partNumber.toString().padStart(6, "0");
|
|
@@ -553,13 +572,14 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
553
572
|
* Completes a multipart upload by committing the blocks to create the blob.
|
|
554
573
|
*
|
|
555
574
|
* @param {string} blobName - The name of the blob for which the multipart upload is being completed.
|
|
556
|
-
* @param {string} uploadId - The ID of the multipart upload to be completed.
|
|
557
575
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.
|
|
558
576
|
* @throws {Error} If no block IDs are found in the metadata.
|
|
559
577
|
*/
|
|
560
|
-
async completeMultipartUpload(blobName
|
|
578
|
+
async completeMultipartUpload(blobName) {
|
|
561
579
|
var _a;
|
|
562
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
580
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
581
|
+
this.containerName
|
|
582
|
+
);
|
|
563
583
|
const blobClient = containerClient.getBlockBlobClient(blobName);
|
|
564
584
|
const listMultipartUploads = await this.listMultipartUploadsForKey(blobName);
|
|
565
585
|
const blockIds = ((_a = listMultipartUploads == null ? void 0 : listMultipartUploads.Parts) == null ? void 0 : _a.map((part) => part.ETag)) || [];
|
|
@@ -576,7 +596,9 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
576
596
|
* @return {Promise<void>} A promise that resolves when the multipart upload is successfully aborted.
|
|
577
597
|
*/
|
|
578
598
|
async abortMultipartUpload(blobName, uploadId) {
|
|
579
|
-
const containerClient = this.blobServiceClient.getContainerClient(
|
|
599
|
+
const containerClient = this.blobServiceClient.getContainerClient(
|
|
600
|
+
this.containerName
|
|
601
|
+
);
|
|
580
602
|
const blobClient = containerClient.getBlockBlobClient(blobName);
|
|
581
603
|
const blockIdStorage = BlockIdStorage.getInstance();
|
|
582
604
|
blockIdStorage.clearBlockIds(uploadId);
|
|
@@ -585,13 +607,15 @@ var _BlobStorageService = class _BlobStorageService {
|
|
|
585
607
|
async getMultipartUploadPresignedUrl(blobName, uploadId, partNumber, expiresInMinutes = 2) {
|
|
586
608
|
const partId = partNumber.toString().padStart(6, "0");
|
|
587
609
|
const partIdBase64 = Buffer.from(partId).toString("base64");
|
|
588
|
-
const sasUrl = await this.getSignatureUrl(
|
|
610
|
+
const sasUrl = await this.getSignatureUrl(
|
|
611
|
+
blobName,
|
|
612
|
+
expiresInMinutes,
|
|
613
|
+
"w"
|
|
614
|
+
);
|
|
589
615
|
const url = `${sasUrl}&comp=block&blockid=${partIdBase64}`;
|
|
590
616
|
return url;
|
|
591
617
|
}
|
|
592
618
|
};
|
|
593
|
-
__name(_BlobStorageService, "BlobStorageService");
|
|
594
|
-
var BlobStorageService = _BlobStorageService;
|
|
595
619
|
|
|
596
620
|
// src/services/storage/s3/s3Helpers.ts
|
|
597
621
|
function listResponseContentsToListResponseItems(responseContents) {
|
|
@@ -604,7 +628,6 @@ function listResponseContentsToListResponseItems(responseContents) {
|
|
|
604
628
|
};
|
|
605
629
|
});
|
|
606
630
|
}
|
|
607
|
-
__name(listResponseContentsToListResponseItems, "listResponseContentsToListResponseItems");
|
|
608
631
|
function s3ObjectToObjectResponse(s3Object) {
|
|
609
632
|
return {
|
|
610
633
|
body: s3Object.Body,
|
|
@@ -619,23 +642,469 @@ function s3ObjectToObjectResponse(s3Object) {
|
|
|
619
642
|
lastModified: s3Object.LastModified
|
|
620
643
|
};
|
|
621
644
|
}
|
|
622
|
-
|
|
623
|
-
|
|
645
|
+
|
|
646
|
+
// node_modules/@smithy/types/dist-es/auth/auth.js
|
|
647
|
+
var HttpAuthLocation;
|
|
648
|
+
(function(HttpAuthLocation2) {
|
|
649
|
+
HttpAuthLocation2["HEADER"] = "header";
|
|
650
|
+
HttpAuthLocation2["QUERY"] = "query";
|
|
651
|
+
})(HttpAuthLocation || (HttpAuthLocation = {}));
|
|
652
|
+
|
|
653
|
+
// node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
|
|
654
|
+
var HttpApiKeyAuthLocation;
|
|
655
|
+
(function(HttpApiKeyAuthLocation2) {
|
|
656
|
+
HttpApiKeyAuthLocation2["HEADER"] = "header";
|
|
657
|
+
HttpApiKeyAuthLocation2["QUERY"] = "query";
|
|
658
|
+
})(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
|
|
659
|
+
|
|
660
|
+
// node_modules/@smithy/types/dist-es/endpoint.js
|
|
661
|
+
var EndpointURLScheme;
|
|
662
|
+
(function(EndpointURLScheme2) {
|
|
663
|
+
EndpointURLScheme2["HTTP"] = "http";
|
|
664
|
+
EndpointURLScheme2["HTTPS"] = "https";
|
|
665
|
+
})(EndpointURLScheme || (EndpointURLScheme = {}));
|
|
666
|
+
|
|
667
|
+
// node_modules/@smithy/types/dist-es/extensions/checksum.js
|
|
668
|
+
var AlgorithmId;
|
|
669
|
+
(function(AlgorithmId2) {
|
|
670
|
+
AlgorithmId2["MD5"] = "md5";
|
|
671
|
+
AlgorithmId2["CRC32"] = "crc32";
|
|
672
|
+
AlgorithmId2["CRC32C"] = "crc32c";
|
|
673
|
+
AlgorithmId2["SHA1"] = "sha1";
|
|
674
|
+
AlgorithmId2["SHA256"] = "sha256";
|
|
675
|
+
})(AlgorithmId || (AlgorithmId = {}));
|
|
676
|
+
|
|
677
|
+
// node_modules/@smithy/types/dist-es/http.js
|
|
678
|
+
var FieldPosition;
|
|
679
|
+
(function(FieldPosition2) {
|
|
680
|
+
FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
|
|
681
|
+
FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
|
|
682
|
+
})(FieldPosition || (FieldPosition = {}));
|
|
683
|
+
|
|
684
|
+
// node_modules/@smithy/types/dist-es/profile.js
|
|
685
|
+
var IniSectionType;
|
|
686
|
+
(function(IniSectionType2) {
|
|
687
|
+
IniSectionType2["PROFILE"] = "profile";
|
|
688
|
+
IniSectionType2["SSO_SESSION"] = "sso-session";
|
|
689
|
+
IniSectionType2["SERVICES"] = "services";
|
|
690
|
+
})(IniSectionType || (IniSectionType = {}));
|
|
691
|
+
|
|
692
|
+
// node_modules/@smithy/types/dist-es/transfer.js
|
|
693
|
+
var RequestHandlerProtocol;
|
|
694
|
+
(function(RequestHandlerProtocol2) {
|
|
695
|
+
RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
|
|
696
|
+
RequestHandlerProtocol2["HTTP_1_0"] = "http/1.0";
|
|
697
|
+
RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
|
|
698
|
+
})(RequestHandlerProtocol || (RequestHandlerProtocol = {}));
|
|
699
|
+
|
|
700
|
+
// node_modules/@smithy/protocol-http/dist-es/httpResponse.js
|
|
701
|
+
var HttpResponse = class {
|
|
702
|
+
constructor(options) {
|
|
703
|
+
this.statusCode = options.statusCode;
|
|
704
|
+
this.reason = options.reason;
|
|
705
|
+
this.headers = options.headers || {};
|
|
706
|
+
this.body = options.body;
|
|
707
|
+
}
|
|
708
|
+
static isInstance(response) {
|
|
709
|
+
if (!response)
|
|
710
|
+
return false;
|
|
711
|
+
const resp = response;
|
|
712
|
+
return typeof resp.statusCode === "number" && typeof resp.headers === "object";
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
// node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
|
|
717
|
+
var escapeUri = (uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
|
|
718
|
+
var hexEncode = (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
|
|
719
|
+
|
|
720
|
+
// node_modules/@smithy/querystring-builder/dist-es/index.js
|
|
721
|
+
function buildQueryString(query) {
|
|
722
|
+
const parts = [];
|
|
723
|
+
for (let key of Object.keys(query).sort()) {
|
|
724
|
+
const value = query[key];
|
|
725
|
+
key = escapeUri(key);
|
|
726
|
+
if (Array.isArray(value)) {
|
|
727
|
+
for (let i = 0, iLen = value.length; i < iLen; i++) {
|
|
728
|
+
parts.push(`${key}=${escapeUri(value[i])}`);
|
|
729
|
+
}
|
|
730
|
+
} else {
|
|
731
|
+
let qsEntry = key;
|
|
732
|
+
if (value || typeof value === "string") {
|
|
733
|
+
qsEntry += `=${escapeUri(value)}`;
|
|
734
|
+
}
|
|
735
|
+
parts.push(qsEntry);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
return parts.join("&");
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// node_modules/@smithy/node-http-handler/dist-es/constants.js
|
|
742
|
+
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
743
|
+
|
|
744
|
+
// node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
|
|
745
|
+
var getTransformedHeaders = (headers) => {
|
|
746
|
+
const transformedHeaders = {};
|
|
747
|
+
for (const name of Object.keys(headers)) {
|
|
748
|
+
const headerValues = headers[name];
|
|
749
|
+
transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
|
|
750
|
+
}
|
|
751
|
+
return transformedHeaders;
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
// node_modules/@smithy/node-http-handler/dist-es/timing.js
|
|
755
|
+
var timing = {
|
|
756
|
+
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
757
|
+
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
// node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
|
|
761
|
+
var DEFER_EVENT_LISTENER_TIME = 1e3;
|
|
762
|
+
var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
763
|
+
if (!timeoutInMs) {
|
|
764
|
+
return -1;
|
|
765
|
+
}
|
|
766
|
+
const registerTimeout = (offset) => {
|
|
767
|
+
const timeoutId = timing.setTimeout(() => {
|
|
768
|
+
request.destroy();
|
|
769
|
+
reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
|
|
770
|
+
name: "TimeoutError"
|
|
771
|
+
}));
|
|
772
|
+
}, timeoutInMs - offset);
|
|
773
|
+
const doWithSocket = (socket) => {
|
|
774
|
+
if (socket == null ? void 0 : socket.connecting) {
|
|
775
|
+
socket.on("connect", () => {
|
|
776
|
+
timing.clearTimeout(timeoutId);
|
|
777
|
+
});
|
|
778
|
+
} else {
|
|
779
|
+
timing.clearTimeout(timeoutId);
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
if (request.socket) {
|
|
783
|
+
doWithSocket(request.socket);
|
|
784
|
+
} else {
|
|
785
|
+
request.on("socket", doWithSocket);
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
if (timeoutInMs < 2e3) {
|
|
789
|
+
registerTimeout(0);
|
|
790
|
+
return 0;
|
|
791
|
+
}
|
|
792
|
+
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
// node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
|
|
796
|
+
var DEFER_EVENT_LISTENER_TIME2 = 3e3;
|
|
797
|
+
var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
|
|
798
|
+
if (keepAlive !== true) {
|
|
799
|
+
return -1;
|
|
800
|
+
}
|
|
801
|
+
const registerListener = () => {
|
|
802
|
+
if (request.socket) {
|
|
803
|
+
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
804
|
+
} else {
|
|
805
|
+
request.on("socket", (socket) => {
|
|
806
|
+
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
if (deferTimeMs === 0) {
|
|
811
|
+
registerListener();
|
|
812
|
+
return 0;
|
|
813
|
+
}
|
|
814
|
+
return timing.setTimeout(registerListener, deferTimeMs);
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
// node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
|
|
818
|
+
var DEFER_EVENT_LISTENER_TIME3 = 3e3;
|
|
819
|
+
var setSocketTimeout = (request, reject, timeoutInMs = DEFAULT_REQUEST_TIMEOUT) => {
|
|
820
|
+
const registerTimeout = (offset) => {
|
|
821
|
+
const timeout = timeoutInMs - offset;
|
|
822
|
+
const onTimeout = () => {
|
|
823
|
+
request.destroy();
|
|
824
|
+
reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
|
|
825
|
+
};
|
|
826
|
+
if (request.socket) {
|
|
827
|
+
request.socket.setTimeout(timeout, onTimeout);
|
|
828
|
+
request.on("close", () => {
|
|
829
|
+
var _a;
|
|
830
|
+
return (_a = request.socket) == null ? void 0 : _a.removeListener("timeout", onTimeout);
|
|
831
|
+
});
|
|
832
|
+
} else {
|
|
833
|
+
request.setTimeout(timeout, onTimeout);
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
if (0 < timeoutInMs && timeoutInMs < 6e3) {
|
|
837
|
+
registerTimeout(0);
|
|
838
|
+
return 0;
|
|
839
|
+
}
|
|
840
|
+
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), DEFER_EVENT_LISTENER_TIME3);
|
|
841
|
+
};
|
|
842
|
+
var MIN_WAIT_TIME = 6e3;
|
|
843
|
+
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
|
|
844
|
+
var _a;
|
|
845
|
+
const headers = (_a = request.headers) != null ? _a : {};
|
|
846
|
+
const expect = headers["Expect"] || headers["expect"];
|
|
847
|
+
let timeoutId = -1;
|
|
848
|
+
let sendBody = true;
|
|
849
|
+
if (expect === "100-continue") {
|
|
850
|
+
sendBody = await Promise.race([
|
|
851
|
+
new Promise((resolve) => {
|
|
852
|
+
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
853
|
+
}),
|
|
854
|
+
new Promise((resolve) => {
|
|
855
|
+
httpRequest.on("continue", () => {
|
|
856
|
+
timing.clearTimeout(timeoutId);
|
|
857
|
+
resolve(true);
|
|
858
|
+
});
|
|
859
|
+
httpRequest.on("response", () => {
|
|
860
|
+
timing.clearTimeout(timeoutId);
|
|
861
|
+
resolve(false);
|
|
862
|
+
});
|
|
863
|
+
httpRequest.on("error", () => {
|
|
864
|
+
timing.clearTimeout(timeoutId);
|
|
865
|
+
resolve(false);
|
|
866
|
+
});
|
|
867
|
+
})
|
|
868
|
+
]);
|
|
869
|
+
}
|
|
870
|
+
if (sendBody) {
|
|
871
|
+
writeBody(httpRequest, request.body);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
function writeBody(httpRequest, body) {
|
|
875
|
+
if (body instanceof stream2.Readable) {
|
|
876
|
+
body.pipe(httpRequest);
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
if (body) {
|
|
880
|
+
if (Buffer.isBuffer(body) || typeof body === "string") {
|
|
881
|
+
httpRequest.end(body);
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
const uint8 = body;
|
|
885
|
+
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
|
|
886
|
+
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
httpRequest.end(Buffer.from(body));
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
httpRequest.end();
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
|
|
896
|
+
var DEFAULT_REQUEST_TIMEOUT = 0;
|
|
897
|
+
var NodeHttpHandler = class _NodeHttpHandler {
|
|
898
|
+
static create(instanceOrOptions) {
|
|
899
|
+
if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
|
|
900
|
+
return instanceOrOptions;
|
|
901
|
+
}
|
|
902
|
+
return new _NodeHttpHandler(instanceOrOptions);
|
|
903
|
+
}
|
|
904
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
|
|
905
|
+
var _a, _b, _c, _d, _e;
|
|
906
|
+
const { sockets, requests, maxSockets } = agent;
|
|
907
|
+
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
908
|
+
return socketWarningTimestamp;
|
|
909
|
+
}
|
|
910
|
+
const interval = 15e3;
|
|
911
|
+
if (Date.now() - interval < socketWarningTimestamp) {
|
|
912
|
+
return socketWarningTimestamp;
|
|
913
|
+
}
|
|
914
|
+
if (sockets && requests) {
|
|
915
|
+
for (const origin in sockets) {
|
|
916
|
+
const socketsInUse = (_b = (_a = sockets[origin]) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
917
|
+
const requestsEnqueued = (_d = (_c = requests[origin]) == null ? void 0 : _c.length) != null ? _d : 0;
|
|
918
|
+
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
919
|
+
(_e = logger == null ? void 0 : logger.warn) == null ? void 0 : _e.call(logger, `@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
920
|
+
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
921
|
+
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
922
|
+
return Date.now();
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
return socketWarningTimestamp;
|
|
927
|
+
}
|
|
928
|
+
constructor(options) {
|
|
929
|
+
this.socketWarningTimestamp = 0;
|
|
930
|
+
this.metadata = { handlerProtocol: "http/1.1" };
|
|
931
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
932
|
+
if (typeof options === "function") {
|
|
933
|
+
options().then((_options) => {
|
|
934
|
+
resolve(this.resolveDefaultConfig(_options));
|
|
935
|
+
}).catch(reject);
|
|
936
|
+
} else {
|
|
937
|
+
resolve(this.resolveDefaultConfig(options));
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
resolveDefaultConfig(options) {
|
|
942
|
+
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent } = options || {};
|
|
943
|
+
const keepAlive = true;
|
|
944
|
+
const maxSockets = 50;
|
|
945
|
+
return {
|
|
946
|
+
connectionTimeout,
|
|
947
|
+
requestTimeout: requestTimeout != null ? requestTimeout : socketTimeout,
|
|
948
|
+
socketAcquisitionWarningTimeout,
|
|
949
|
+
httpAgent: (() => {
|
|
950
|
+
if (httpAgent instanceof http.Agent || typeof (httpAgent == null ? void 0 : httpAgent.destroy) === "function") {
|
|
951
|
+
return httpAgent;
|
|
952
|
+
}
|
|
953
|
+
return new http.Agent(__spreadValues({ keepAlive, maxSockets }, httpAgent));
|
|
954
|
+
})(),
|
|
955
|
+
httpsAgent: (() => {
|
|
956
|
+
if (httpsAgent instanceof https.Agent || typeof (httpsAgent == null ? void 0 : httpsAgent.destroy) === "function") {
|
|
957
|
+
return httpsAgent;
|
|
958
|
+
}
|
|
959
|
+
return new https.Agent(__spreadValues({ keepAlive, maxSockets }, httpsAgent));
|
|
960
|
+
})(),
|
|
961
|
+
logger: console
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
destroy() {
|
|
965
|
+
var _a, _b, _c, _d;
|
|
966
|
+
(_b = (_a = this.config) == null ? void 0 : _a.httpAgent) == null ? void 0 : _b.destroy();
|
|
967
|
+
(_d = (_c = this.config) == null ? void 0 : _c.httpsAgent) == null ? void 0 : _d.destroy();
|
|
968
|
+
}
|
|
969
|
+
async handle(request, { abortSignal, requestTimeout } = {}) {
|
|
970
|
+
if (!this.config) {
|
|
971
|
+
this.config = await this.configProvider;
|
|
972
|
+
}
|
|
973
|
+
return new Promise((_resolve, _reject) => {
|
|
974
|
+
var _a, _b, _c, _d, _e, _f;
|
|
975
|
+
let writeRequestBodyPromise = void 0;
|
|
976
|
+
const timeouts = [];
|
|
977
|
+
const resolve = async (arg) => {
|
|
978
|
+
await writeRequestBodyPromise;
|
|
979
|
+
timeouts.forEach(timing.clearTimeout);
|
|
980
|
+
_resolve(arg);
|
|
981
|
+
};
|
|
982
|
+
const reject = async (arg) => {
|
|
983
|
+
await writeRequestBodyPromise;
|
|
984
|
+
timeouts.forEach(timing.clearTimeout);
|
|
985
|
+
_reject(arg);
|
|
986
|
+
};
|
|
987
|
+
if (!this.config) {
|
|
988
|
+
throw new Error("Node HTTP request handler config is not resolved");
|
|
989
|
+
}
|
|
990
|
+
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
991
|
+
const abortError = new Error("Request aborted");
|
|
992
|
+
abortError.name = "AbortError";
|
|
993
|
+
reject(abortError);
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
const isSSL = request.protocol === "https:";
|
|
997
|
+
const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
|
|
998
|
+
timeouts.push(timing.setTimeout(() => {
|
|
999
|
+
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, this.config.logger);
|
|
1000
|
+
}, (_c = this.config.socketAcquisitionWarningTimeout) != null ? _c : ((_a = this.config.requestTimeout) != null ? _a : 2e3) + ((_b = this.config.connectionTimeout) != null ? _b : 1e3)));
|
|
1001
|
+
const queryString = buildQueryString(request.query || {});
|
|
1002
|
+
let auth = void 0;
|
|
1003
|
+
if (request.username != null || request.password != null) {
|
|
1004
|
+
const username = (_d = request.username) != null ? _d : "";
|
|
1005
|
+
const password = (_e = request.password) != null ? _e : "";
|
|
1006
|
+
auth = `${username}:${password}`;
|
|
1007
|
+
}
|
|
1008
|
+
let path = request.path;
|
|
1009
|
+
if (queryString) {
|
|
1010
|
+
path += `?${queryString}`;
|
|
1011
|
+
}
|
|
1012
|
+
if (request.fragment) {
|
|
1013
|
+
path += `#${request.fragment}`;
|
|
1014
|
+
}
|
|
1015
|
+
let hostname = (_f = request.hostname) != null ? _f : "";
|
|
1016
|
+
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
1017
|
+
hostname = request.hostname.slice(1, -1);
|
|
1018
|
+
} else {
|
|
1019
|
+
hostname = request.hostname;
|
|
1020
|
+
}
|
|
1021
|
+
const nodeHttpsOptions = {
|
|
1022
|
+
headers: request.headers,
|
|
1023
|
+
host: hostname,
|
|
1024
|
+
method: request.method,
|
|
1025
|
+
path,
|
|
1026
|
+
port: request.port,
|
|
1027
|
+
agent,
|
|
1028
|
+
auth
|
|
1029
|
+
};
|
|
1030
|
+
const requestFunc = isSSL ? https.request : http.request;
|
|
1031
|
+
const req = requestFunc(nodeHttpsOptions, (res) => {
|
|
1032
|
+
const httpResponse = new HttpResponse({
|
|
1033
|
+
statusCode: res.statusCode || -1,
|
|
1034
|
+
reason: res.statusMessage,
|
|
1035
|
+
headers: getTransformedHeaders(res.headers),
|
|
1036
|
+
body: res
|
|
1037
|
+
});
|
|
1038
|
+
resolve({ response: httpResponse });
|
|
1039
|
+
});
|
|
1040
|
+
req.on("error", (err) => {
|
|
1041
|
+
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
1042
|
+
reject(Object.assign(err, { name: "TimeoutError" }));
|
|
1043
|
+
} else {
|
|
1044
|
+
reject(err);
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
if (abortSignal) {
|
|
1048
|
+
const onAbort = () => {
|
|
1049
|
+
req.destroy();
|
|
1050
|
+
const abortError = new Error("Request aborted");
|
|
1051
|
+
abortError.name = "AbortError";
|
|
1052
|
+
reject(abortError);
|
|
1053
|
+
};
|
|
1054
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
1055
|
+
const signal = abortSignal;
|
|
1056
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1057
|
+
req.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
1058
|
+
} else {
|
|
1059
|
+
abortSignal.onabort = onAbort;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
const effectiveRequestTimeout = requestTimeout != null ? requestTimeout : this.config.requestTimeout;
|
|
1063
|
+
timeouts.push(setConnectionTimeout(req, reject, this.config.connectionTimeout));
|
|
1064
|
+
timeouts.push(setSocketTimeout(req, reject, effectiveRequestTimeout));
|
|
1065
|
+
const httpAgent = nodeHttpsOptions.agent;
|
|
1066
|
+
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
1067
|
+
timeouts.push(setSocketKeepAlive(req, {
|
|
1068
|
+
keepAlive: httpAgent.keepAlive,
|
|
1069
|
+
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
1070
|
+
}));
|
|
1071
|
+
}
|
|
1072
|
+
writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout).catch((e) => {
|
|
1073
|
+
timeouts.forEach(timing.clearTimeout);
|
|
1074
|
+
return _reject(e);
|
|
1075
|
+
});
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
updateHttpClientConfig(key, value) {
|
|
1079
|
+
this.config = void 0;
|
|
1080
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
1081
|
+
return __spreadProps(__spreadValues({}, config), {
|
|
1082
|
+
[key]: value
|
|
1083
|
+
});
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
httpHandlerConfigs() {
|
|
1087
|
+
var _a;
|
|
1088
|
+
return (_a = this.config) != null ? _a : {};
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
// src/services/storage/s3/s3Storage.service.ts
|
|
1093
|
+
var S3StorageService = class {
|
|
624
1094
|
constructor(bucketName, options) {
|
|
625
|
-
|
|
1095
|
+
this.httpHandler = new NodeHttpHandler({
|
|
626
1096
|
socketTimeout: 6e5
|
|
627
|
-
})
|
|
628
|
-
|
|
1097
|
+
});
|
|
1098
|
+
this.s3Client = new clientS3.S3Client({
|
|
629
1099
|
region: process.env.AWS_DEFAULT_REGION,
|
|
630
1100
|
requestHandler: this.httpHandler,
|
|
631
1101
|
credentials: credentialProviderNode.defaultProvider()
|
|
632
|
-
})
|
|
633
|
-
|
|
1102
|
+
});
|
|
1103
|
+
this.s3 = new clientS3.S3({
|
|
634
1104
|
region: process.env.AWS_DEFAULT_REGION,
|
|
635
1105
|
requestHandler: this.httpHandler,
|
|
636
1106
|
credentials: credentialProviderNode.defaultProvider()
|
|
637
|
-
})
|
|
638
|
-
__publicField(this, "bucketName");
|
|
1107
|
+
});
|
|
639
1108
|
var _a, _b, _c, _d;
|
|
640
1109
|
this.bucketName = bucketName;
|
|
641
1110
|
if (((_a = options == null ? void 0 : options.credentials) == null ? void 0 : _a.accessKeyId) && ((_b = options == null ? void 0 : options.credentials) == null ? void 0 : _b.secretAccessKey)) {
|
|
@@ -680,7 +1149,11 @@ var _S3StorageService = class _S3StorageService {
|
|
|
680
1149
|
let continueListing = true;
|
|
681
1150
|
while (continueListing) {
|
|
682
1151
|
const listChunkLimit = limit - responseContents.length;
|
|
683
|
-
const response = await this.listChunk(
|
|
1152
|
+
const response = await this.listChunk(
|
|
1153
|
+
options,
|
|
1154
|
+
continuationToken,
|
|
1155
|
+
listChunkLimit
|
|
1156
|
+
);
|
|
684
1157
|
continuationToken = response.NextContinuationToken;
|
|
685
1158
|
responseContents = responseContents.concat((_b = response.Contents) != null ? _b : []);
|
|
686
1159
|
if (responseContents.length >= limit || !continuationToken) {
|
|
@@ -722,16 +1195,10 @@ var _S3StorageService = class _S3StorageService {
|
|
|
722
1195
|
pagination
|
|
723
1196
|
}));
|
|
724
1197
|
if ((_a = response.items) == null ? void 0 : _a.length)
|
|
725
|
-
allItems = [
|
|
726
|
-
...allItems,
|
|
727
|
-
...response.items
|
|
728
|
-
];
|
|
1198
|
+
allItems = [...allItems, ...response.items];
|
|
729
1199
|
pagination = response.pagination === null ? void 0 : response.pagination;
|
|
730
1200
|
} while (pagination);
|
|
731
|
-
return {
|
|
732
|
-
items: allItems,
|
|
733
|
-
count: allItems.length
|
|
734
|
-
};
|
|
1201
|
+
return { items: allItems, count: allItems.length };
|
|
735
1202
|
}
|
|
736
1203
|
/**
|
|
737
1204
|
* Retrieves an object from the S3 bucket.
|
|
@@ -771,9 +1238,7 @@ var _S3StorageService = class _S3StorageService {
|
|
|
771
1238
|
Bucket: this.bucketName,
|
|
772
1239
|
Key: key
|
|
773
1240
|
});
|
|
774
|
-
return s3RequestPresigner.getSignedUrl(this.s3Client, command, {
|
|
775
|
-
expiresIn
|
|
776
|
-
});
|
|
1241
|
+
return s3RequestPresigner.getSignedUrl(this.s3Client, command, { expiresIn });
|
|
777
1242
|
}
|
|
778
1243
|
/**
|
|
779
1244
|
* Retrieves a signed URL for uploading an object to the S3 bucket.
|
|
@@ -806,6 +1271,22 @@ var _S3StorageService = class _S3StorageService {
|
|
|
806
1271
|
* @returns A promise that resolves to the response containing the key of the uploaded object.
|
|
807
1272
|
*/
|
|
808
1273
|
async upload(key, body, metadata) {
|
|
1274
|
+
if (body instanceof stream2__default.default.Readable) {
|
|
1275
|
+
const upload = new libStorage.Upload({
|
|
1276
|
+
client: this.s3Client,
|
|
1277
|
+
params: {
|
|
1278
|
+
Bucket: this.bucketName,
|
|
1279
|
+
Key: key,
|
|
1280
|
+
Body: body,
|
|
1281
|
+
Metadata: metadata
|
|
1282
|
+
},
|
|
1283
|
+
queueSize: 5,
|
|
1284
|
+
partSize: 8 * 1024 * 1024
|
|
1285
|
+
// 8MB parts
|
|
1286
|
+
});
|
|
1287
|
+
await upload.done();
|
|
1288
|
+
return { key };
|
|
1289
|
+
}
|
|
809
1290
|
const command = new clientS3.PutObjectCommand({
|
|
810
1291
|
Bucket: this.bucketName,
|
|
811
1292
|
Key: key,
|
|
@@ -813,9 +1294,7 @@ var _S3StorageService = class _S3StorageService {
|
|
|
813
1294
|
Metadata: metadata
|
|
814
1295
|
});
|
|
815
1296
|
await this.s3Client.send(command);
|
|
816
|
-
return {
|
|
817
|
-
key
|
|
818
|
-
};
|
|
1297
|
+
return { key };
|
|
819
1298
|
}
|
|
820
1299
|
/**
|
|
821
1300
|
* Creates a writable stream for uploading a file to the S3 bucket.
|
|
@@ -824,7 +1303,7 @@ var _S3StorageService = class _S3StorageService {
|
|
|
824
1303
|
* @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.
|
|
825
1304
|
*/
|
|
826
1305
|
createUploadWriteStream(key) {
|
|
827
|
-
const streamPassThrough = new
|
|
1306
|
+
const streamPassThrough = new stream2__default.default.PassThrough();
|
|
828
1307
|
const params = {
|
|
829
1308
|
Bucket: this.bucketName,
|
|
830
1309
|
Key: key,
|
|
@@ -862,7 +1341,9 @@ var _S3StorageService = class _S3StorageService {
|
|
|
862
1341
|
});
|
|
863
1342
|
return this.s3Client.send(command);
|
|
864
1343
|
} catch (error) {
|
|
865
|
-
throw new Error(
|
|
1344
|
+
throw new Error(
|
|
1345
|
+
"Error in S3 getHeadContainer. bucketName: " + this.bucketName + " Error: " + error
|
|
1346
|
+
);
|
|
866
1347
|
}
|
|
867
1348
|
}
|
|
868
1349
|
/**
|
|
@@ -939,7 +1420,10 @@ var _S3StorageService = class _S3StorageService {
|
|
|
939
1420
|
return upId;
|
|
940
1421
|
}
|
|
941
1422
|
async completeMultipartUpload(key, uploadId) {
|
|
942
|
-
const partsResponse = await this.listMultipartUploadsForKey(
|
|
1423
|
+
const partsResponse = await this.listMultipartUploadsForKey(
|
|
1424
|
+
key,
|
|
1425
|
+
uploadId
|
|
1426
|
+
);
|
|
943
1427
|
const partsList = (partsResponse == null ? void 0 : partsResponse.Parts) && partsResponse.Parts.map(
|
|
944
1428
|
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
945
1429
|
(_a) => {
|
|
@@ -973,23 +1457,353 @@ var _S3StorageService = class _S3StorageService {
|
|
|
973
1457
|
PartNumber: parseInt(partNumber, 10)
|
|
974
1458
|
};
|
|
975
1459
|
const expiresIn = expiresInMinutes * 60;
|
|
976
|
-
const presignedUrl = await s3RequestPresigner.getSignedUrl(
|
|
977
|
-
|
|
978
|
-
|
|
1460
|
+
const presignedUrl = await s3RequestPresigner.getSignedUrl(
|
|
1461
|
+
this.s3Client,
|
|
1462
|
+
new clientS3.UploadPartCommand(uploadPartParams),
|
|
1463
|
+
{ expiresIn }
|
|
1464
|
+
);
|
|
979
1465
|
return presignedUrl;
|
|
980
1466
|
}
|
|
981
1467
|
};
|
|
982
|
-
|
|
983
|
-
var
|
|
1468
|
+
var SftpClient = __require("ssh2-sftp-client");
|
|
1469
|
+
var SftpStorageService = class {
|
|
1470
|
+
constructor(bucketName, options) {
|
|
1471
|
+
this.bucketName = bucketName;
|
|
1472
|
+
this.options = options || {};
|
|
1473
|
+
this.client = new SftpClient();
|
|
1474
|
+
}
|
|
1475
|
+
async initializeClient() {
|
|
1476
|
+
const host = this.options.host || process.env.SFTP_HOST;
|
|
1477
|
+
const port = parseInt(
|
|
1478
|
+
String(this.options.port || process.env.SFTP_PORT)
|
|
1479
|
+
);
|
|
1480
|
+
const user = this.options.user || process.env.SFTP_USER;
|
|
1481
|
+
const password = this.options.password || process.env.SFTP_PASSWORD;
|
|
1482
|
+
const privateKey = this.options.privateKey || process.env.SFTP_PRIVATE_KEY;
|
|
1483
|
+
if (!password && !privateKey) {
|
|
1484
|
+
throw new Error(
|
|
1485
|
+
"Either password or private key must be provided for SFTP connection"
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
1488
|
+
await this.client.connect({
|
|
1489
|
+
host,
|
|
1490
|
+
port,
|
|
1491
|
+
username: user,
|
|
1492
|
+
password,
|
|
1493
|
+
privateKey,
|
|
1494
|
+
readyTimeout: 4e3,
|
|
1495
|
+
retries: 1,
|
|
1496
|
+
retry_factor: 2,
|
|
1497
|
+
retry_minTimeout: 2e3
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
async withClient(fn) {
|
|
1501
|
+
try {
|
|
1502
|
+
await this.initializeClient();
|
|
1503
|
+
return await fn();
|
|
1504
|
+
} finally {
|
|
1505
|
+
await this.client.end().catch(() => {
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
async list(options) {
|
|
1510
|
+
return this.withClient(async () => {
|
|
1511
|
+
const prefix = options.prefix || "";
|
|
1512
|
+
const path = this.bucketName + (prefix ? "/" + prefix : "");
|
|
1513
|
+
const list = await this.client.list(path);
|
|
1514
|
+
const items = list.map((item) => ({
|
|
1515
|
+
key: item.name,
|
|
1516
|
+
lastModified: item.modifyTime ? new Date(item.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1517
|
+
size: item.size,
|
|
1518
|
+
eTag: ""
|
|
1519
|
+
}));
|
|
1520
|
+
return {
|
|
1521
|
+
items,
|
|
1522
|
+
pagination: null,
|
|
1523
|
+
count: items.length
|
|
1524
|
+
};
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
async ensureDirectoriesExist(remotePath) {
|
|
1528
|
+
var _a, _b;
|
|
1529
|
+
const parts = remotePath.split("/");
|
|
1530
|
+
parts.pop();
|
|
1531
|
+
let current = "";
|
|
1532
|
+
for (const part of parts) {
|
|
1533
|
+
if (!part)
|
|
1534
|
+
continue;
|
|
1535
|
+
current += `/${part}`;
|
|
1536
|
+
try {
|
|
1537
|
+
await this.client.stat(current);
|
|
1538
|
+
} catch (err) {
|
|
1539
|
+
const isNoEntry = err.code === "ENOENT" || ((_a = err.message) == null ? void 0 : _a.includes("No such file")) || ((_b = err.message) == null ? void 0 : _b.includes("does not exist"));
|
|
1540
|
+
if (isNoEntry) {
|
|
1541
|
+
try {
|
|
1542
|
+
await this.client.mkdir(current);
|
|
1543
|
+
} catch (mkdirErr) {
|
|
1544
|
+
throw new Error(
|
|
1545
|
+
`Failed to create directory ${current}: ${mkdirErr.message}`
|
|
1546
|
+
);
|
|
1547
|
+
}
|
|
1548
|
+
} else {
|
|
1549
|
+
throw new Error(
|
|
1550
|
+
`Failed to check directory ${current}: ${err.message}`
|
|
1551
|
+
);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
async upload(key, body) {
|
|
1557
|
+
return this.withClient(async () => {
|
|
1558
|
+
let remotePath = `${this.bucketName}/${key}`;
|
|
1559
|
+
remotePath = remotePath + "";
|
|
1560
|
+
await this.ensureDirectoriesExist(remotePath);
|
|
1561
|
+
if (body instanceof stream2.Readable) {
|
|
1562
|
+
await this.client.put(body, remotePath);
|
|
1563
|
+
} else if (body instanceof Buffer) {
|
|
1564
|
+
await this.client.put(Buffer.from(body), remotePath);
|
|
1565
|
+
} else {
|
|
1566
|
+
await this.client.put(Buffer.from(String(body)), remotePath);
|
|
1567
|
+
}
|
|
1568
|
+
return { key };
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
async delete(key) {
|
|
1572
|
+
return this.withClient(async () => {
|
|
1573
|
+
await this.client.delete(`${this.bucketName}/${key}`);
|
|
1574
|
+
return true;
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
async getObject(key) {
|
|
1578
|
+
await this.initializeClient();
|
|
1579
|
+
const remotePath = `${this.bucketName}/${key}`;
|
|
1580
|
+
const stats = await this.client.stat(remotePath);
|
|
1581
|
+
const data = await this.client.get(remotePath);
|
|
1582
|
+
let stream3;
|
|
1583
|
+
if (Buffer.isBuffer(data) || typeof data === "string") {
|
|
1584
|
+
stream3 = stream2.Readable.from(data);
|
|
1585
|
+
} else if (data instanceof stream2.Readable) {
|
|
1586
|
+
stream3 = data;
|
|
1587
|
+
} else {
|
|
1588
|
+
throw new Error("Unsupported stream type returned by SFTP client");
|
|
1589
|
+
}
|
|
1590
|
+
const cleanup = async () => {
|
|
1591
|
+
try {
|
|
1592
|
+
await this.client.end();
|
|
1593
|
+
} catch (e) {
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
stream3.on("end", cleanup);
|
|
1597
|
+
stream3.on("error", cleanup);
|
|
1598
|
+
return {
|
|
1599
|
+
body: stream3,
|
|
1600
|
+
contentLength: stats.size,
|
|
1601
|
+
lastModified: stats.modifyTime ? new Date(stats.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1602
|
+
metadata: {}
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
listAll(options) {
|
|
1606
|
+
throw new Error("Method not implemented.");
|
|
1607
|
+
}
|
|
1608
|
+
getHeadObject(key) {
|
|
1609
|
+
throw new Error("Method not implemented.");
|
|
1610
|
+
}
|
|
1611
|
+
getDownloadUrl(key, expiresInMinutes) {
|
|
1612
|
+
throw new Error("Method not implemented.");
|
|
1613
|
+
}
|
|
1614
|
+
getUploadUrl(key, expiresInMinutes) {
|
|
1615
|
+
throw new Error("Method not implemented.");
|
|
1616
|
+
}
|
|
1617
|
+
createUploadWriteStream(key) {
|
|
1618
|
+
throw new Error("Method not implemented.");
|
|
1619
|
+
}
|
|
1620
|
+
getHeadBucket() {
|
|
1621
|
+
throw new Error("Method not implemented.");
|
|
1622
|
+
}
|
|
1623
|
+
generateUploadIdMultipart(key) {
|
|
1624
|
+
throw new Error("Method not implemented.");
|
|
1625
|
+
}
|
|
1626
|
+
listMultipartUploadsForBucket() {
|
|
1627
|
+
throw new Error("Method not implemented.");
|
|
1628
|
+
}
|
|
1629
|
+
listMultipartUploadsForKey(key, uploadId) {
|
|
1630
|
+
throw new Error("Method not implemented.");
|
|
1631
|
+
}
|
|
1632
|
+
uploadMultipart(key, file, partNumber, uploadId) {
|
|
1633
|
+
throw new Error("Method not implemented.");
|
|
1634
|
+
}
|
|
1635
|
+
completeMultipartUpload(key, uploadId) {
|
|
1636
|
+
throw new Error("Method not implemented.");
|
|
1637
|
+
}
|
|
1638
|
+
abortMultipartUpload(key, uploadId) {
|
|
1639
|
+
throw new Error("Method not implemented.");
|
|
1640
|
+
}
|
|
1641
|
+
getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
|
|
1642
|
+
throw new Error("Method not implemented.");
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
var FtpStorageService = class {
|
|
1646
|
+
constructor(bucketName, options) {
|
|
1647
|
+
this.bucketName = bucketName;
|
|
1648
|
+
this.options = options || {};
|
|
1649
|
+
this.client = new basicFtp.Client();
|
|
1650
|
+
}
|
|
1651
|
+
listAll(options) {
|
|
1652
|
+
throw new Error("Method not implemented.");
|
|
1653
|
+
}
|
|
1654
|
+
async initializeClient() {
|
|
1655
|
+
var _a, _b, _c, _d, _e;
|
|
1656
|
+
const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
|
|
1657
|
+
const port = parseInt(
|
|
1658
|
+
String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
|
|
1659
|
+
10
|
|
1660
|
+
);
|
|
1661
|
+
const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
|
|
1662
|
+
const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
|
|
1663
|
+
await this.client.access({
|
|
1664
|
+
host,
|
|
1665
|
+
port,
|
|
1666
|
+
user,
|
|
1667
|
+
password,
|
|
1668
|
+
secure: ((_e = this == null ? void 0 : this.options) == null ? void 0 : _e.secure) || false
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
async withClient(fn) {
|
|
1672
|
+
try {
|
|
1673
|
+
await this.initializeClient();
|
|
1674
|
+
return await fn();
|
|
1675
|
+
} finally {
|
|
1676
|
+
this.client.close();
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
async list(options) {
|
|
1680
|
+
return this.withClient(async () => {
|
|
1681
|
+
const prefix = options.prefix || "";
|
|
1682
|
+
const path = `${this.bucketName}/${prefix}`;
|
|
1683
|
+
try {
|
|
1684
|
+
const list = await this.client.list(path);
|
|
1685
|
+
const items = list.map(
|
|
1686
|
+
(item) => ({
|
|
1687
|
+
key: prefix + item.name,
|
|
1688
|
+
lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
|
|
1689
|
+
size: item.size,
|
|
1690
|
+
eTag: ""
|
|
1691
|
+
})
|
|
1692
|
+
);
|
|
1693
|
+
return {
|
|
1694
|
+
items,
|
|
1695
|
+
pagination: null,
|
|
1696
|
+
count: items.length
|
|
1697
|
+
};
|
|
1698
|
+
} catch (e) {
|
|
1699
|
+
return { items: [], pagination: null, count: 0 };
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
async getObject(key) {
|
|
1704
|
+
await this.initializeClient();
|
|
1705
|
+
const passThrough = new stream2.PassThrough();
|
|
1706
|
+
const path = `${this.bucketName}/${key}`;
|
|
1707
|
+
const stats = await this.client.size(path);
|
|
1708
|
+
this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
|
|
1709
|
+
const cleanup = () => {
|
|
1710
|
+
this.client.close();
|
|
1711
|
+
};
|
|
1712
|
+
passThrough.on("end", cleanup);
|
|
1713
|
+
passThrough.on("error", cleanup);
|
|
1714
|
+
return {
|
|
1715
|
+
body: passThrough,
|
|
1716
|
+
contentLength: stats,
|
|
1717
|
+
lastModified: /* @__PURE__ */ new Date(),
|
|
1718
|
+
metadata: {}
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
async upload(key, body) {
|
|
1722
|
+
return this.withClient(async () => {
|
|
1723
|
+
await this.client.cd("/");
|
|
1724
|
+
try {
|
|
1725
|
+
await this.client.cd(this.bucketName);
|
|
1726
|
+
} catch (e) {
|
|
1727
|
+
await this.client.send(`MKD ${this.bucketName}`);
|
|
1728
|
+
await this.client.cd(this.bucketName);
|
|
1729
|
+
}
|
|
1730
|
+
const parts = key.split("/");
|
|
1731
|
+
parts.pop();
|
|
1732
|
+
for (const part of parts) {
|
|
1733
|
+
if (!part)
|
|
1734
|
+
continue;
|
|
1735
|
+
try {
|
|
1736
|
+
await this.client.cd(part);
|
|
1737
|
+
} catch (e) {
|
|
1738
|
+
await this.client.send(`MKD ${part}`);
|
|
1739
|
+
await this.client.cd(part);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
await this.client.cd("/");
|
|
1743
|
+
const fullPath = `${this.bucketName}/${key}`;
|
|
1744
|
+
const stream3 = body instanceof stream2.Readable ? body : stream2.Readable.from([body]);
|
|
1745
|
+
await this.client.uploadFrom(stream3, fullPath);
|
|
1746
|
+
return { key };
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
async delete(key) {
|
|
1750
|
+
return this.withClient(async () => {
|
|
1751
|
+
await this.client.remove(`${this.bucketName}/${key}`);
|
|
1752
|
+
return true;
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
async close() {
|
|
1756
|
+
this.client.close();
|
|
1757
|
+
}
|
|
1758
|
+
// Unsupported Operations
|
|
1759
|
+
async getDownloadUrl(_key, _expiresInMinutes) {
|
|
1760
|
+
throw new Error("FTP does not support pre-signed URLs");
|
|
1761
|
+
}
|
|
1762
|
+
async getUploadUrl(_key, _expiresInMinutes) {
|
|
1763
|
+
throw new Error("FTP does not support pre-signed URLs");
|
|
1764
|
+
}
|
|
1765
|
+
async getHeadObject(_key) {
|
|
1766
|
+
throw new Error("Operation not supported");
|
|
1767
|
+
}
|
|
1768
|
+
createUploadWriteStream(_key) {
|
|
1769
|
+
throw new Error("Operation not supported");
|
|
1770
|
+
}
|
|
1771
|
+
async getHeadBucket() {
|
|
1772
|
+
throw new Error("Operation not supported");
|
|
1773
|
+
}
|
|
1774
|
+
async generateUploadIdMultipart(_key) {
|
|
1775
|
+
throw new Error("Multipart upload is not supported");
|
|
1776
|
+
}
|
|
1777
|
+
async listMultipartUploadsForBucket() {
|
|
1778
|
+
throw new Error("Multipart upload is not supported");
|
|
1779
|
+
}
|
|
1780
|
+
async listMultipartUploadsForKey(_key, _uploadId) {
|
|
1781
|
+
throw new Error("Multipart upload is not supported");
|
|
1782
|
+
}
|
|
1783
|
+
async uploadMultipart(_key, _file, _partNumber, _uploadId) {
|
|
1784
|
+
throw new Error("Multipart upload is not supported");
|
|
1785
|
+
}
|
|
1786
|
+
async completeMultipartUpload(_key, _uploadId) {
|
|
1787
|
+
throw new Error("Multipart upload is not supported");
|
|
1788
|
+
}
|
|
1789
|
+
async abortMultipartUpload(_key, _uploadId) {
|
|
1790
|
+
throw new Error("Method not implemented.");
|
|
1791
|
+
}
|
|
1792
|
+
async getMultipartUploadPresignedUrl(_key, _uploadId, _partNumber, _expiresInMinutes) {
|
|
1793
|
+
throw new Error("Multipart upload is not supported");
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
984
1796
|
|
|
985
1797
|
// src/shared/utils/constants.ts
|
|
986
1798
|
var OBJECT_STORAGE_SERVICE_TYPES = {
|
|
987
1799
|
AWS_S3: "aws_s3",
|
|
988
|
-
AZURE_BLOB_STORAGE: "azure_blob_storage"
|
|
1800
|
+
AZURE_BLOB_STORAGE: "azure_blob_storage",
|
|
1801
|
+
FTP: "ftp",
|
|
1802
|
+
SFTP: "sftp"
|
|
989
1803
|
};
|
|
990
1804
|
|
|
991
1805
|
// src/services/objectStorageFactory.service.ts
|
|
992
|
-
var
|
|
1806
|
+
var ObjectStorageFactory = class {
|
|
993
1807
|
static async instance(bucketName, options) {
|
|
994
1808
|
var _a, _b;
|
|
995
1809
|
const provider = ((_a = options == null ? void 0 : options.provider) == null ? void 0 : _a.toLowerCase()) || ((_b = process.env.OBJECT_STORAGE_SERVICE) == null ? void 0 : _b.toLowerCase());
|
|
@@ -997,17 +1811,21 @@ var _ObjectStorageFactory = class _ObjectStorageFactory {
|
|
|
997
1811
|
case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:
|
|
998
1812
|
return new S3StorageService(bucketName, options);
|
|
999
1813
|
case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:
|
|
1000
|
-
return new BlobStorageService(bucketName);
|
|
1814
|
+
return new BlobStorageService(bucketName, options);
|
|
1815
|
+
case OBJECT_STORAGE_SERVICE_TYPES.FTP:
|
|
1816
|
+
return new FtpStorageService(bucketName, options);
|
|
1817
|
+
case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
|
|
1818
|
+
return new SftpStorageService(bucketName, options);
|
|
1001
1819
|
default:
|
|
1002
|
-
throw new Error(
|
|
1820
|
+
throw new Error(
|
|
1821
|
+
`Unsupported object storage provider: ${provider}`
|
|
1822
|
+
);
|
|
1003
1823
|
}
|
|
1004
1824
|
}
|
|
1005
1825
|
};
|
|
1006
|
-
__name(_ObjectStorageFactory, "ObjectStorageFactory");
|
|
1007
|
-
var ObjectStorageFactory = _ObjectStorageFactory;
|
|
1008
1826
|
|
|
1009
1827
|
// src/services/objectStorage.service.ts
|
|
1010
|
-
var
|
|
1828
|
+
var ObjectStorageService = class _ObjectStorageService {
|
|
1011
1829
|
constructor(bucketName, options) {
|
|
1012
1830
|
_ObjectStorageService.bucketName = bucketName;
|
|
1013
1831
|
if (options)
|
|
@@ -1023,38 +1841,56 @@ var _ObjectStorageService = class _ObjectStorageService {
|
|
|
1023
1841
|
*
|
|
1024
1842
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1025
1843
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1844
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1026
1845
|
* @return {Promise<ListResponse>} A promise that resolves to the list of objects.
|
|
1027
1846
|
*/
|
|
1028
|
-
static async list(options, bucketName) {
|
|
1029
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1847
|
+
static async list(options, bucketName, objectStorageOptions) {
|
|
1848
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1849
|
+
bucketName,
|
|
1850
|
+
objectStorageOptions
|
|
1851
|
+
).then((instance) => instance.list(options));
|
|
1030
1852
|
}
|
|
1031
1853
|
/**
|
|
1032
1854
|
* Retrieves a list of all objects from the object storage service.
|
|
1033
1855
|
*
|
|
1034
1856
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1035
1857
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1858
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1036
1859
|
* @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
|
|
1037
1860
|
*/
|
|
1038
|
-
static async listAll(options, bucketName) {
|
|
1039
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1861
|
+
static async listAll(options, bucketName, objectStorageOptions) {
|
|
1862
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1863
|
+
bucketName,
|
|
1864
|
+
objectStorageOptions
|
|
1865
|
+
).then((instance) => instance.listAll(options));
|
|
1040
1866
|
}
|
|
1041
1867
|
/**
|
|
1042
1868
|
* Retrieves an object from the object storage service.
|
|
1043
1869
|
*
|
|
1044
1870
|
* @param {string} key - The key of the object to retrieve.
|
|
1045
1871
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1872
|
+
* @param {IGetObjectOptions} [options] - The options to apply to the get operation.
|
|
1873
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1046
1874
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
|
|
1047
1875
|
*/
|
|
1048
|
-
static async getObject(key, bucketName, options) {
|
|
1049
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1876
|
+
static async getObject(key, bucketName, options, objectStorageOptions) {
|
|
1877
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1878
|
+
bucketName,
|
|
1879
|
+
objectStorageOptions
|
|
1880
|
+
).then((instance) => instance.getObject(key, options));
|
|
1050
1881
|
}
|
|
1051
1882
|
/**
|
|
1052
1883
|
* Retrieves an object info (without file content) from the object storage service.
|
|
1053
1884
|
* @param key - The key of the object to retrieve.
|
|
1885
|
+
* @param bucketName - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1886
|
+
* @param objectStorageOptions - The options for the object storage service.
|
|
1054
1887
|
* @returns A promise that resolves to the info of the file.
|
|
1055
1888
|
*/
|
|
1056
|
-
static async getHeadObject(key, bucketName) {
|
|
1057
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1889
|
+
static async getHeadObject(key, bucketName, objectStorageOptions) {
|
|
1890
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1891
|
+
bucketName,
|
|
1892
|
+
objectStorageOptions
|
|
1893
|
+
).then((instance) => instance.getHeadObject(key));
|
|
1058
1894
|
}
|
|
1059
1895
|
/**
|
|
1060
1896
|
* Retrieves a signed URL for the specified object in the object storage service.
|
|
@@ -1062,10 +1898,14 @@ var _ObjectStorageService = class _ObjectStorageService {
|
|
|
1062
1898
|
* @param {string} key - The key of the object for which to generate the signed URL.
|
|
1063
1899
|
* @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
|
|
1064
1900
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1901
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1065
1902
|
* @return {Promise<string>} A promise that resolves to the generated signed URL.
|
|
1066
1903
|
*/
|
|
1067
|
-
static async getDownloadUrl(key, expiresInMinutes, bucketName) {
|
|
1068
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1904
|
+
static async getDownloadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
|
|
1905
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1906
|
+
bucketName,
|
|
1907
|
+
objectStorageOptions
|
|
1908
|
+
).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
|
|
1069
1909
|
}
|
|
1070
1910
|
/**
|
|
1071
1911
|
* Retrieves an upload URL for the specified object in the object storage service.
|
|
@@ -1073,10 +1913,14 @@ var _ObjectStorageService = class _ObjectStorageService {
|
|
|
1073
1913
|
* @param {string} key - The key of the object for which to generate the upload URL.
|
|
1074
1914
|
* @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
|
|
1075
1915
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1916
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1076
1917
|
* @return {Promise<string>} A promise that resolves to the generated upload URL.
|
|
1077
1918
|
*/
|
|
1078
|
-
static async getUploadUrl(key, expiresInMinutes, bucketName) {
|
|
1079
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1919
|
+
static async getUploadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
|
|
1920
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1921
|
+
bucketName,
|
|
1922
|
+
objectStorageOptions
|
|
1923
|
+
).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
|
|
1080
1924
|
}
|
|
1081
1925
|
/**
|
|
1082
1926
|
* Uploads a file to the object storage service.
|
|
@@ -1085,39 +1929,48 @@ var _ObjectStorageService = class _ObjectStorageService {
|
|
|
1085
1929
|
* @param {FileContent} body - The content of the file to upload.
|
|
1086
1930
|
* @param {Object} [metadata] - Optional metadata to associate with the object.
|
|
1087
1931
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1932
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1088
1933
|
* @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
|
|
1089
1934
|
*/
|
|
1090
|
-
static async upload(key, body, metadata, bucketName) {
|
|
1091
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1935
|
+
static async upload(key, body, metadata, bucketName, objectStorageOptions) {
|
|
1936
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1937
|
+
bucketName,
|
|
1938
|
+
objectStorageOptions
|
|
1939
|
+
).then((instance) => instance.upload(key, body, metadata));
|
|
1092
1940
|
}
|
|
1093
1941
|
/**
|
|
1094
1942
|
* Creates an upload write stream for the specified key in the object storage service.
|
|
1095
1943
|
*
|
|
1096
1944
|
* @param {string} key - The key of the object to create the upload write stream for.
|
|
1097
1945
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1946
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1098
1947
|
* @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
|
|
1099
1948
|
*/
|
|
1100
|
-
static async createUploadWriteStream(key, bucketName) {
|
|
1101
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1949
|
+
static async createUploadWriteStream(key, bucketName, objectStorageOptions) {
|
|
1950
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1951
|
+
bucketName,
|
|
1952
|
+
objectStorageOptions
|
|
1953
|
+
).then((instance) => instance.createUploadWriteStream(key));
|
|
1102
1954
|
}
|
|
1103
1955
|
/**
|
|
1104
1956
|
* Deletes an object or multiple objects from the object storage service.
|
|
1105
1957
|
*
|
|
1106
1958
|
* @param {string | string[]} key - The key or array of keys of the objects to delete.
|
|
1107
1959
|
* @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.
|
|
1960
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1108
1961
|
* @return {Promise<{ key: string; deleted: boolean; error?: string }[] | boolean>} A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each object deleted, or a boolean value indicating the success of the deletion.
|
|
1109
1962
|
*/
|
|
1110
|
-
static async delete(key, bucketName) {
|
|
1111
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1963
|
+
static async delete(key, bucketName, objectStorageOptions) {
|
|
1964
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1965
|
+
bucketName,
|
|
1966
|
+
objectStorageOptions
|
|
1967
|
+
).then(async (instance) => {
|
|
1112
1968
|
if (Array.isArray(key)) {
|
|
1113
1969
|
const deleteBlobPromises = key.map(async (blobName) => {
|
|
1114
1970
|
var _a;
|
|
1115
1971
|
try {
|
|
1116
1972
|
await instance.delete(blobName);
|
|
1117
|
-
return {
|
|
1118
|
-
key: blobName,
|
|
1119
|
-
deleted: true
|
|
1120
|
-
};
|
|
1973
|
+
return { key: blobName, deleted: true };
|
|
1121
1974
|
} catch (error) {
|
|
1122
1975
|
return {
|
|
1123
1976
|
key: blobName,
|
|
@@ -1136,20 +1989,28 @@ var _ObjectStorageService = class _ObjectStorageService {
|
|
|
1136
1989
|
* Retrieves the head bucket from the object storage service.
|
|
1137
1990
|
*
|
|
1138
1991
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1992
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1139
1993
|
* @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
|
|
1140
1994
|
*/
|
|
1141
|
-
static async getHeadBucket(bucketName) {
|
|
1142
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1995
|
+
static async getHeadBucket(bucketName, objectStorageOptions) {
|
|
1996
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1997
|
+
bucketName,
|
|
1998
|
+
objectStorageOptions
|
|
1999
|
+
).then((instance) => instance.getHeadBucket());
|
|
1143
2000
|
}
|
|
1144
2001
|
/**
|
|
1145
2002
|
* Generates a unique upload ID for a multipart upload.
|
|
1146
2003
|
*
|
|
1147
2004
|
* @param {string} key - The key of the object to upload.
|
|
1148
2005
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
2006
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1149
2007
|
* @return {Promise<string>} A promise that resolves to the generated upload ID.
|
|
1150
2008
|
*/
|
|
1151
|
-
static async generateUploadIdMultipart(key, bucketName) {
|
|
1152
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2009
|
+
static async generateUploadIdMultipart(key, bucketName, objectStorageOptions) {
|
|
2010
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2011
|
+
bucketName,
|
|
2012
|
+
objectStorageOptions
|
|
2013
|
+
).then((instance) => instance.generateUploadIdMultipart(key));
|
|
1153
2014
|
}
|
|
1154
2015
|
/**
|
|
1155
2016
|
* Retrieves a list of multipart uploads for a specified key in the object storage service.
|
|
@@ -1157,19 +2018,29 @@ var _ObjectStorageService = class _ObjectStorageService {
|
|
|
1157
2018
|
* @param {string} key - The key of the object to retrieve uploads for.
|
|
1158
2019
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1159
2020
|
* @param {string} [uploadId] - The upload ID to filter the results by.
|
|
2021
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1160
2022
|
* @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
|
|
1161
2023
|
*/
|
|
1162
|
-
static async listMultipartUploadsForKey(key, bucketName, uploadId) {
|
|
1163
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2024
|
+
static async listMultipartUploadsForKey(key, bucketName, uploadId, objectStorageOptions) {
|
|
2025
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2026
|
+
bucketName,
|
|
2027
|
+
objectStorageOptions
|
|
2028
|
+
).then(
|
|
2029
|
+
(instance) => instance.listMultipartUploadsForKey(key, uploadId)
|
|
2030
|
+
);
|
|
1164
2031
|
}
|
|
1165
2032
|
/**
|
|
1166
2033
|
* Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
|
|
1167
2034
|
*
|
|
1168
2035
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
2036
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1169
2037
|
* @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
|
|
1170
2038
|
*/
|
|
1171
|
-
static async listMultipartUploadsForBucket(bucketName) {
|
|
1172
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2039
|
+
static async listMultipartUploadsForBucket(bucketName, objectStorageOptions) {
|
|
2040
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2041
|
+
bucketName,
|
|
2042
|
+
objectStorageOptions
|
|
2043
|
+
).then((instance) => instance.listMultipartUploadsForBucket());
|
|
1173
2044
|
}
|
|
1174
2045
|
/**
|
|
1175
2046
|
* Uploads a multipart file to the specified bucket in the object storage service.
|
|
@@ -1179,10 +2050,16 @@ var _ObjectStorageService = class _ObjectStorageService {
|
|
|
1179
2050
|
* @param {number} partNumber - The number of the part being uploaded.
|
|
1180
2051
|
* @param {string} [uploadId] - The ID of the multipart upload.
|
|
1181
2052
|
* @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.
|
|
2053
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1182
2054
|
* @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
|
|
1183
2055
|
*/
|
|
1184
|
-
static async uploadMultipart(key, file, partNumber, uploadId, bucketName) {
|
|
1185
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2056
|
+
static async uploadMultipart(key, file, partNumber, uploadId, bucketName, objectStorageOptions) {
|
|
2057
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2058
|
+
bucketName,
|
|
2059
|
+
objectStorageOptions
|
|
2060
|
+
).then(
|
|
2061
|
+
(instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
|
|
2062
|
+
);
|
|
1186
2063
|
}
|
|
1187
2064
|
/**
|
|
1188
2065
|
* Completes a multipart upload for the specified object in the object storage service.
|
|
@@ -1190,10 +2067,14 @@ var _ObjectStorageService = class _ObjectStorageService {
|
|
|
1190
2067
|
* @param {string} key - The key of the object to complete the multipart upload for.
|
|
1191
2068
|
* @param {string} uploadId - The ID of the multipart upload to complete.
|
|
1192
2069
|
* @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.
|
|
2070
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1193
2071
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
|
|
1194
2072
|
*/
|
|
1195
|
-
static async completeMultipartUpload(key, uploadId, bucketName) {
|
|
1196
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2073
|
+
static async completeMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
|
|
2074
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2075
|
+
bucketName,
|
|
2076
|
+
objectStorageOptions
|
|
2077
|
+
).then((instance) => instance.completeMultipartUpload(key, uploadId));
|
|
1197
2078
|
}
|
|
1198
2079
|
/**
|
|
1199
2080
|
* Aborts a multipart upload for the specified object in the object storage service.
|
|
@@ -1201,10 +2082,14 @@ var _ObjectStorageService = class _ObjectStorageService {
|
|
|
1201
2082
|
* @param {string} key - The key of the object to abort the multipart upload for.
|
|
1202
2083
|
* @param {string} uploadId - The ID of the multipart upload to abort.
|
|
1203
2084
|
* @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.
|
|
2085
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1204
2086
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
|
|
1205
2087
|
*/
|
|
1206
|
-
static async abortMultipartUpload(key, uploadId, bucketName) {
|
|
1207
|
-
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2088
|
+
static async abortMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
|
|
2089
|
+
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2090
|
+
bucketName,
|
|
2091
|
+
objectStorageOptions
|
|
2092
|
+
).then((instance) => instance.abortMultipartUpload(key, uploadId));
|
|
1208
2093
|
}
|
|
1209
2094
|
/**
|
|
1210
2095
|
* Retrieves a presigned URL for a specific part of a multipart upload.
|
|
@@ -1216,13 +2101,16 @@ var _ObjectStorageService = class _ObjectStorageService {
|
|
|
1216
2101
|
* @return {Promise<string>} A Promise that resolves to the presigned URL for the specified part of the multipart upload.
|
|
1217
2102
|
*/
|
|
1218
2103
|
static async getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
|
|
1219
|
-
return _ObjectStorageService.getObjectStorageServiceInstance().then(
|
|
2104
|
+
return _ObjectStorageService.getObjectStorageServiceInstance().then(
|
|
2105
|
+
(instance) => instance.getMultipartUploadPresignedUrl(
|
|
2106
|
+
key,
|
|
2107
|
+
uploadId,
|
|
2108
|
+
partNumber,
|
|
2109
|
+
expiresInMinutes
|
|
2110
|
+
)
|
|
2111
|
+
);
|
|
1220
2112
|
}
|
|
1221
2113
|
};
|
|
1222
|
-
__name(_ObjectStorageService, "ObjectStorageService");
|
|
1223
|
-
__publicField(_ObjectStorageService, "bucketName");
|
|
1224
|
-
__publicField(_ObjectStorageService, "objectStorageOptions");
|
|
1225
|
-
var ObjectStorageService = _ObjectStorageService;
|
|
1226
2114
|
|
|
1227
2115
|
exports.ObjectStorageService = ObjectStorageService;
|
|
1228
2116
|
//# sourceMappingURL=out.js.map
|