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