@qrvey/object-storage 1.0.2-beta → 1.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/dist/cjs/index.js +528 -108
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +45 -19
- package/dist/esm/index.mjs +529 -109
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +45 -19
- package/package.json +7 -3
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import stream, { Readable } from 'stream';
|
|
1
|
+
import stream, { Readable, PassThrough } from 'stream';
|
|
2
2
|
import { BlobServiceClient, BlobSASPermissions } from '@azure/storage-blob';
|
|
3
3
|
import { S3Client, S3, ListObjectsV2Command, HeadObjectCommand, GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadBucketCommand, UploadPartCommand } from '@aws-sdk/client-s3';
|
|
4
4
|
import { defaultProvider } from '@aws-sdk/credential-provider-node';
|
|
@@ -6,6 +6,7 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
|
6
6
|
import { Upload } from '@aws-sdk/lib-storage';
|
|
7
7
|
import { Agent, request as request$1 } from 'http';
|
|
8
8
|
import { Agent as Agent$1, request } from 'https';
|
|
9
|
+
import { Client } from 'basic-ftp';
|
|
9
10
|
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __defProps = Object.defineProperties;
|
|
@@ -31,6 +32,13 @@ var __spreadValues = (a, b) => {
|
|
|
31
32
|
return a;
|
|
32
33
|
};
|
|
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
|
+
});
|
|
34
42
|
var __objRest = (source, exclude) => {
|
|
35
43
|
var target = {};
|
|
36
44
|
for (var prop in source)
|
|
@@ -132,12 +140,13 @@ var BlobStorageService = class {
|
|
|
132
140
|
* Retrieves the properties of a blob from the container by its name.
|
|
133
141
|
*
|
|
134
142
|
* @param {string} blobName - The name of the blob.
|
|
143
|
+
* @param {ObjectStorageOptions} options - The options for the object storage service.
|
|
135
144
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
|
|
136
145
|
*/
|
|
137
|
-
constructor(containerName) {
|
|
146
|
+
constructor(containerName, options) {
|
|
138
147
|
this.containerName = containerName;
|
|
139
148
|
this.blobServiceClient = BlobServiceClient.fromConnectionString(
|
|
140
|
-
process.env.AZURE_STORAGE_CONNECTION_STRING
|
|
149
|
+
(options == null ? void 0 : options.connectionString) || process.env.AZURE_STORAGE_CONNECTION_STRING
|
|
141
150
|
);
|
|
142
151
|
}
|
|
143
152
|
/**
|
|
@@ -557,11 +566,10 @@ var BlobStorageService = class {
|
|
|
557
566
|
* Completes a multipart upload by committing the blocks to create the blob.
|
|
558
567
|
*
|
|
559
568
|
* @param {string} blobName - The name of the blob for which the multipart upload is being completed.
|
|
560
|
-
* @param {string} uploadId - The ID of the multipart upload to be completed.
|
|
561
569
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.
|
|
562
570
|
* @throws {Error} If no block IDs are found in the metadata.
|
|
563
571
|
*/
|
|
564
|
-
async completeMultipartUpload(blobName
|
|
572
|
+
async completeMultipartUpload(blobName) {
|
|
565
573
|
var _a;
|
|
566
574
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
567
575
|
this.containerName
|
|
@@ -629,28 +637,28 @@ function s3ObjectToObjectResponse(s3Object) {
|
|
|
629
637
|
};
|
|
630
638
|
}
|
|
631
639
|
|
|
632
|
-
//
|
|
640
|
+
// node_modules/@smithy/types/dist-es/auth/auth.js
|
|
633
641
|
var HttpAuthLocation;
|
|
634
642
|
(function(HttpAuthLocation2) {
|
|
635
643
|
HttpAuthLocation2["HEADER"] = "header";
|
|
636
644
|
HttpAuthLocation2["QUERY"] = "query";
|
|
637
645
|
})(HttpAuthLocation || (HttpAuthLocation = {}));
|
|
638
646
|
|
|
639
|
-
//
|
|
647
|
+
// node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
|
|
640
648
|
var HttpApiKeyAuthLocation;
|
|
641
649
|
(function(HttpApiKeyAuthLocation2) {
|
|
642
650
|
HttpApiKeyAuthLocation2["HEADER"] = "header";
|
|
643
651
|
HttpApiKeyAuthLocation2["QUERY"] = "query";
|
|
644
652
|
})(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
|
|
645
653
|
|
|
646
|
-
//
|
|
654
|
+
// node_modules/@smithy/types/dist-es/endpoint.js
|
|
647
655
|
var EndpointURLScheme;
|
|
648
656
|
(function(EndpointURLScheme2) {
|
|
649
657
|
EndpointURLScheme2["HTTP"] = "http";
|
|
650
658
|
EndpointURLScheme2["HTTPS"] = "https";
|
|
651
659
|
})(EndpointURLScheme || (EndpointURLScheme = {}));
|
|
652
660
|
|
|
653
|
-
//
|
|
661
|
+
// node_modules/@smithy/types/dist-es/extensions/checksum.js
|
|
654
662
|
var AlgorithmId;
|
|
655
663
|
(function(AlgorithmId2) {
|
|
656
664
|
AlgorithmId2["MD5"] = "md5";
|
|
@@ -660,14 +668,14 @@ var AlgorithmId;
|
|
|
660
668
|
AlgorithmId2["SHA256"] = "sha256";
|
|
661
669
|
})(AlgorithmId || (AlgorithmId = {}));
|
|
662
670
|
|
|
663
|
-
//
|
|
671
|
+
// node_modules/@smithy/types/dist-es/http.js
|
|
664
672
|
var FieldPosition;
|
|
665
673
|
(function(FieldPosition2) {
|
|
666
674
|
FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
|
|
667
675
|
FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
|
|
668
676
|
})(FieldPosition || (FieldPosition = {}));
|
|
669
677
|
|
|
670
|
-
//
|
|
678
|
+
// node_modules/@smithy/types/dist-es/profile.js
|
|
671
679
|
var IniSectionType;
|
|
672
680
|
(function(IniSectionType2) {
|
|
673
681
|
IniSectionType2["PROFILE"] = "profile";
|
|
@@ -675,7 +683,7 @@ var IniSectionType;
|
|
|
675
683
|
IniSectionType2["SERVICES"] = "services";
|
|
676
684
|
})(IniSectionType || (IniSectionType = {}));
|
|
677
685
|
|
|
678
|
-
//
|
|
686
|
+
// node_modules/@smithy/types/dist-es/transfer.js
|
|
679
687
|
var RequestHandlerProtocol;
|
|
680
688
|
(function(RequestHandlerProtocol2) {
|
|
681
689
|
RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
|
|
@@ -683,7 +691,7 @@ var RequestHandlerProtocol;
|
|
|
683
691
|
RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
|
|
684
692
|
})(RequestHandlerProtocol || (RequestHandlerProtocol = {}));
|
|
685
693
|
|
|
686
|
-
//
|
|
694
|
+
// node_modules/@smithy/protocol-http/dist-es/httpResponse.js
|
|
687
695
|
var HttpResponse = class {
|
|
688
696
|
constructor(options) {
|
|
689
697
|
this.statusCode = options.statusCode;
|
|
@@ -699,11 +707,11 @@ var HttpResponse = class {
|
|
|
699
707
|
}
|
|
700
708
|
};
|
|
701
709
|
|
|
702
|
-
//
|
|
710
|
+
// node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
|
|
703
711
|
var escapeUri = (uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
|
|
704
712
|
var hexEncode = (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
|
|
705
713
|
|
|
706
|
-
//
|
|
714
|
+
// node_modules/@smithy/querystring-builder/dist-es/index.js
|
|
707
715
|
function buildQueryString(query) {
|
|
708
716
|
const parts = [];
|
|
709
717
|
for (let key of Object.keys(query).sort()) {
|
|
@@ -724,10 +732,10 @@ function buildQueryString(query) {
|
|
|
724
732
|
return parts.join("&");
|
|
725
733
|
}
|
|
726
734
|
|
|
727
|
-
//
|
|
735
|
+
// node_modules/@smithy/node-http-handler/dist-es/constants.js
|
|
728
736
|
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
729
737
|
|
|
730
|
-
//
|
|
738
|
+
// node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
|
|
731
739
|
var getTransformedHeaders = (headers) => {
|
|
732
740
|
const transformedHeaders = {};
|
|
733
741
|
for (const name of Object.keys(headers)) {
|
|
@@ -737,71 +745,123 @@ var getTransformedHeaders = (headers) => {
|
|
|
737
745
|
return transformedHeaders;
|
|
738
746
|
};
|
|
739
747
|
|
|
740
|
-
//
|
|
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;
|
|
741
756
|
var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
742
757
|
if (!timeoutInMs) {
|
|
743
|
-
return;
|
|
758
|
+
return -1;
|
|
744
759
|
}
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
socket.
|
|
754
|
-
|
|
755
|
-
|
|
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);
|
|
756
778
|
} else {
|
|
757
|
-
|
|
779
|
+
request.on("socket", doWithSocket);
|
|
758
780
|
}
|
|
759
|
-
}
|
|
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);
|
|
760
787
|
};
|
|
761
788
|
|
|
762
|
-
//
|
|
763
|
-
var
|
|
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) => {
|
|
764
792
|
if (keepAlive !== true) {
|
|
765
|
-
return;
|
|
793
|
+
return -1;
|
|
766
794
|
}
|
|
767
|
-
|
|
768
|
-
socket
|
|
769
|
-
|
|
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);
|
|
770
809
|
};
|
|
771
810
|
|
|
772
|
-
//
|
|
773
|
-
var
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
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);
|
|
778
835
|
};
|
|
779
|
-
var MIN_WAIT_TIME =
|
|
836
|
+
var MIN_WAIT_TIME = 6e3;
|
|
780
837
|
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
|
|
781
838
|
var _a;
|
|
782
839
|
const headers = (_a = request.headers) != null ? _a : {};
|
|
783
840
|
const expect = headers["Expect"] || headers["expect"];
|
|
784
841
|
let timeoutId = -1;
|
|
785
|
-
let
|
|
842
|
+
let sendBody = true;
|
|
786
843
|
if (expect === "100-continue") {
|
|
787
|
-
await Promise.race([
|
|
844
|
+
sendBody = await Promise.race([
|
|
788
845
|
new Promise((resolve) => {
|
|
789
|
-
timeoutId = Number(setTimeout(resolve, Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
846
|
+
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
790
847
|
}),
|
|
791
848
|
new Promise((resolve) => {
|
|
792
849
|
httpRequest.on("continue", () => {
|
|
793
|
-
clearTimeout(timeoutId);
|
|
794
|
-
resolve();
|
|
850
|
+
timing.clearTimeout(timeoutId);
|
|
851
|
+
resolve(true);
|
|
852
|
+
});
|
|
853
|
+
httpRequest.on("response", () => {
|
|
854
|
+
timing.clearTimeout(timeoutId);
|
|
855
|
+
resolve(false);
|
|
795
856
|
});
|
|
796
857
|
httpRequest.on("error", () => {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
resolve();
|
|
858
|
+
timing.clearTimeout(timeoutId);
|
|
859
|
+
resolve(false);
|
|
800
860
|
});
|
|
801
861
|
})
|
|
802
862
|
]);
|
|
803
863
|
}
|
|
804
|
-
if (
|
|
864
|
+
if (sendBody) {
|
|
805
865
|
writeBody(httpRequest, request.body);
|
|
806
866
|
}
|
|
807
867
|
}
|
|
@@ -826,7 +886,8 @@ function writeBody(httpRequest, body) {
|
|
|
826
886
|
httpRequest.end();
|
|
827
887
|
}
|
|
828
888
|
|
|
829
|
-
//
|
|
889
|
+
// node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
|
|
890
|
+
var DEFAULT_REQUEST_TIMEOUT = 0;
|
|
830
891
|
var NodeHttpHandler = class _NodeHttpHandler {
|
|
831
892
|
static create(instanceOrOptions) {
|
|
832
893
|
if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
|
|
@@ -834,8 +895,8 @@ var NodeHttpHandler = class _NodeHttpHandler {
|
|
|
834
895
|
}
|
|
835
896
|
return new _NodeHttpHandler(instanceOrOptions);
|
|
836
897
|
}
|
|
837
|
-
static checkSocketUsage(agent, socketWarningTimestamp) {
|
|
838
|
-
var _a, _b, _c, _d;
|
|
898
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
|
|
899
|
+
var _a, _b, _c, _d, _e;
|
|
839
900
|
const { sockets, requests, maxSockets } = agent;
|
|
840
901
|
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
841
902
|
return socketWarningTimestamp;
|
|
@@ -849,7 +910,9 @@ var NodeHttpHandler = class _NodeHttpHandler {
|
|
|
849
910
|
const socketsInUse = (_b = (_a = sockets[origin]) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
850
911
|
const requestsEnqueued = (_d = (_c = requests[origin]) == null ? void 0 : _c.length) != null ? _d : 0;
|
|
851
912
|
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
852
|
-
|
|
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.`);
|
|
853
916
|
return Date.now();
|
|
854
917
|
}
|
|
855
918
|
}
|
|
@@ -870,12 +933,13 @@ var NodeHttpHandler = class _NodeHttpHandler {
|
|
|
870
933
|
});
|
|
871
934
|
}
|
|
872
935
|
resolveDefaultConfig(options) {
|
|
873
|
-
const { requestTimeout, connectionTimeout, socketTimeout, httpAgent, httpsAgent } = options || {};
|
|
936
|
+
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent } = options || {};
|
|
874
937
|
const keepAlive = true;
|
|
875
938
|
const maxSockets = 50;
|
|
876
939
|
return {
|
|
877
940
|
connectionTimeout,
|
|
878
941
|
requestTimeout: requestTimeout != null ? requestTimeout : socketTimeout,
|
|
942
|
+
socketAcquisitionWarningTimeout,
|
|
879
943
|
httpAgent: (() => {
|
|
880
944
|
if (httpAgent instanceof Agent || typeof (httpAgent == null ? void 0 : httpAgent.destroy) === "function") {
|
|
881
945
|
return httpAgent;
|
|
@@ -887,7 +951,8 @@ var NodeHttpHandler = class _NodeHttpHandler {
|
|
|
887
951
|
return httpsAgent;
|
|
888
952
|
}
|
|
889
953
|
return new Agent$1(__spreadValues({ keepAlive, maxSockets }, httpsAgent));
|
|
890
|
-
})()
|
|
954
|
+
})(),
|
|
955
|
+
logger: console
|
|
891
956
|
};
|
|
892
957
|
}
|
|
893
958
|
destroy() {
|
|
@@ -895,21 +960,22 @@ var NodeHttpHandler = class _NodeHttpHandler {
|
|
|
895
960
|
(_b = (_a = this.config) == null ? void 0 : _a.httpAgent) == null ? void 0 : _b.destroy();
|
|
896
961
|
(_d = (_c = this.config) == null ? void 0 : _c.httpsAgent) == null ? void 0 : _d.destroy();
|
|
897
962
|
}
|
|
898
|
-
async handle(request$2, { abortSignal } = {}) {
|
|
963
|
+
async handle(request$2, { abortSignal, requestTimeout } = {}) {
|
|
899
964
|
if (!this.config) {
|
|
900
965
|
this.config = await this.configProvider;
|
|
901
966
|
}
|
|
902
|
-
let socketCheckTimeoutId;
|
|
903
967
|
return new Promise((_resolve, _reject) => {
|
|
904
|
-
var _a, _b, _c, _d, _e;
|
|
968
|
+
var _a, _b, _c, _d, _e, _f;
|
|
905
969
|
let writeRequestBodyPromise = void 0;
|
|
970
|
+
const timeouts = [];
|
|
906
971
|
const resolve = async (arg) => {
|
|
907
972
|
await writeRequestBodyPromise;
|
|
908
|
-
clearTimeout
|
|
973
|
+
timeouts.forEach(timing.clearTimeout);
|
|
909
974
|
_resolve(arg);
|
|
910
975
|
};
|
|
911
976
|
const reject = async (arg) => {
|
|
912
977
|
await writeRequestBodyPromise;
|
|
978
|
+
timeouts.forEach(timing.clearTimeout);
|
|
913
979
|
_reject(arg);
|
|
914
980
|
};
|
|
915
981
|
if (!this.config) {
|
|
@@ -923,9 +989,9 @@ var NodeHttpHandler = class _NodeHttpHandler {
|
|
|
923
989
|
}
|
|
924
990
|
const isSSL = request$2.protocol === "https:";
|
|
925
991
|
const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
|
|
926
|
-
|
|
927
|
-
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp);
|
|
928
|
-
}, (_c = this.config.socketAcquisitionWarningTimeout) != null ? _c : ((_a = this.config.requestTimeout) != null ? _a : 2e3) + ((_b = this.config.connectionTimeout) != null ? _b : 1e3));
|
|
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)));
|
|
929
995
|
const queryString = buildQueryString(request$2.query || {});
|
|
930
996
|
let auth = void 0;
|
|
931
997
|
if (request$2.username != null || request$2.password != null) {
|
|
@@ -940,9 +1006,15 @@ var NodeHttpHandler = class _NodeHttpHandler {
|
|
|
940
1006
|
if (request$2.fragment) {
|
|
941
1007
|
path += `#${request$2.fragment}`;
|
|
942
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
|
+
}
|
|
943
1015
|
const nodeHttpsOptions = {
|
|
944
1016
|
headers: request$2.headers,
|
|
945
|
-
host:
|
|
1017
|
+
host: hostname,
|
|
946
1018
|
method: request$2.method,
|
|
947
1019
|
path,
|
|
948
1020
|
port: request$2.port,
|
|
@@ -966,24 +1038,35 @@ var NodeHttpHandler = class _NodeHttpHandler {
|
|
|
966
1038
|
reject(err);
|
|
967
1039
|
}
|
|
968
1040
|
});
|
|
969
|
-
setConnectionTimeout(req, reject, this.config.connectionTimeout);
|
|
970
|
-
setSocketTimeout(req, reject, this.config.requestTimeout);
|
|
971
1041
|
if (abortSignal) {
|
|
972
|
-
|
|
973
|
-
req.
|
|
1042
|
+
const onAbort = () => {
|
|
1043
|
+
req.destroy();
|
|
974
1044
|
const abortError = new Error("Request aborted");
|
|
975
1045
|
abortError.name = "AbortError";
|
|
976
1046
|
reject(abortError);
|
|
977
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
|
+
}
|
|
978
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));
|
|
979
1059
|
const httpAgent = nodeHttpsOptions.agent;
|
|
980
1060
|
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
981
|
-
setSocketKeepAlive(req, {
|
|
1061
|
+
timeouts.push(setSocketKeepAlive(req, {
|
|
982
1062
|
keepAlive: httpAgent.keepAlive,
|
|
983
1063
|
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
984
|
-
});
|
|
1064
|
+
}));
|
|
985
1065
|
}
|
|
986
|
-
writeRequestBodyPromise = writeRequestBody(req, request$2,
|
|
1066
|
+
writeRequestBodyPromise = writeRequestBody(req, request$2, effectiveRequestTimeout).catch((e) => {
|
|
1067
|
+
timeouts.forEach(timing.clearTimeout);
|
|
1068
|
+
return _reject(e);
|
|
1069
|
+
});
|
|
987
1070
|
});
|
|
988
1071
|
}
|
|
989
1072
|
updateHttpClientConfig(key, value) {
|
|
@@ -1360,11 +1443,310 @@ var S3StorageService = class {
|
|
|
1360
1443
|
return presignedUrl;
|
|
1361
1444
|
}
|
|
1362
1445
|
};
|
|
1446
|
+
var SftpClient = __require("ssh2-sftp-client");
|
|
1447
|
+
var SftpStorageService = class {
|
|
1448
|
+
constructor(bucketName, options) {
|
|
1449
|
+
this.bucketName = bucketName;
|
|
1450
|
+
this.options = options || {};
|
|
1451
|
+
this.client = new SftpClient();
|
|
1452
|
+
}
|
|
1453
|
+
async initializeClient() {
|
|
1454
|
+
const host = this.options.host || process.env.SFTP_HOST;
|
|
1455
|
+
const port = parseInt(
|
|
1456
|
+
String(this.options.port || process.env.SFTP_PORT)
|
|
1457
|
+
);
|
|
1458
|
+
const user = this.options.user || process.env.SFTP_USER;
|
|
1459
|
+
const password = this.options.password || process.env.SFTP_PASSWORD;
|
|
1460
|
+
const privateKey = this.options.privateKey || process.env.SFTP_PRIVATE_KEY;
|
|
1461
|
+
if (!password && !privateKey) {
|
|
1462
|
+
throw new Error(
|
|
1463
|
+
"Either password or private key must be provided for SFTP connection"
|
|
1464
|
+
);
|
|
1465
|
+
}
|
|
1466
|
+
await this.client.connect({
|
|
1467
|
+
host,
|
|
1468
|
+
port,
|
|
1469
|
+
username: user,
|
|
1470
|
+
password,
|
|
1471
|
+
privateKey,
|
|
1472
|
+
readyTimeout: 4e3,
|
|
1473
|
+
retries: 1,
|
|
1474
|
+
retry_factor: 2,
|
|
1475
|
+
retry_minTimeout: 2e3
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
async withClient(fn) {
|
|
1479
|
+
try {
|
|
1480
|
+
await this.initializeClient();
|
|
1481
|
+
return await fn();
|
|
1482
|
+
} finally {
|
|
1483
|
+
await this.client.end().catch(() => {
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
async list(options) {
|
|
1488
|
+
return this.withClient(async () => {
|
|
1489
|
+
const prefix = options.prefix || "";
|
|
1490
|
+
const path = this.bucketName + (prefix ? "/" + prefix : "");
|
|
1491
|
+
const list = await this.client.list(path);
|
|
1492
|
+
const items = list.map((item) => ({
|
|
1493
|
+
key: item.name,
|
|
1494
|
+
lastModified: item.modifyTime ? new Date(item.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1495
|
+
size: item.size,
|
|
1496
|
+
eTag: ""
|
|
1497
|
+
}));
|
|
1498
|
+
return {
|
|
1499
|
+
items,
|
|
1500
|
+
pagination: null,
|
|
1501
|
+
count: items.length
|
|
1502
|
+
};
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
async upload(key, body) {
|
|
1506
|
+
return this.withClient(async () => {
|
|
1507
|
+
const remotePath = `${this.bucketName}/${key}`;
|
|
1508
|
+
if (body instanceof Readable) {
|
|
1509
|
+
await this.client.put(body, remotePath);
|
|
1510
|
+
} else if (body instanceof Buffer) {
|
|
1511
|
+
await this.client.put(Buffer.from(body), remotePath);
|
|
1512
|
+
} else {
|
|
1513
|
+
await this.client.put(Buffer.from(String(body)), remotePath);
|
|
1514
|
+
}
|
|
1515
|
+
return { key };
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
async delete(key) {
|
|
1519
|
+
return this.withClient(async () => {
|
|
1520
|
+
await this.client.delete(`${this.bucketName}/${key}`);
|
|
1521
|
+
return true;
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
async getObject(key) {
|
|
1525
|
+
await this.initializeClient();
|
|
1526
|
+
const remotePath = `${this.bucketName}/${key}`;
|
|
1527
|
+
const stats = await this.client.stat(remotePath);
|
|
1528
|
+
const data = await this.client.get(remotePath);
|
|
1529
|
+
let stream3;
|
|
1530
|
+
if (Buffer.isBuffer(data) || typeof data === "string") {
|
|
1531
|
+
stream3 = Readable.from(data);
|
|
1532
|
+
} else if (data instanceof Readable) {
|
|
1533
|
+
stream3 = data;
|
|
1534
|
+
} else {
|
|
1535
|
+
throw new Error("Unsupported stream type returned by SFTP client");
|
|
1536
|
+
}
|
|
1537
|
+
const cleanup = async () => {
|
|
1538
|
+
try {
|
|
1539
|
+
await this.client.end();
|
|
1540
|
+
} catch (e) {
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
stream3.on("end", cleanup);
|
|
1544
|
+
stream3.on("error", cleanup);
|
|
1545
|
+
return {
|
|
1546
|
+
body: stream3,
|
|
1547
|
+
contentLength: stats.size,
|
|
1548
|
+
lastModified: stats.modifyTime ? new Date(stats.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1549
|
+
metadata: {}
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
listAll(options) {
|
|
1553
|
+
throw new Error("Method not implemented.");
|
|
1554
|
+
}
|
|
1555
|
+
getHeadObject(key) {
|
|
1556
|
+
throw new Error("Method not implemented.");
|
|
1557
|
+
}
|
|
1558
|
+
getDownloadUrl(key, expiresInMinutes) {
|
|
1559
|
+
throw new Error("Method not implemented.");
|
|
1560
|
+
}
|
|
1561
|
+
getUploadUrl(key, expiresInMinutes) {
|
|
1562
|
+
throw new Error("Method not implemented.");
|
|
1563
|
+
}
|
|
1564
|
+
createUploadWriteStream(key) {
|
|
1565
|
+
throw new Error("Method not implemented.");
|
|
1566
|
+
}
|
|
1567
|
+
getHeadBucket() {
|
|
1568
|
+
throw new Error("Method not implemented.");
|
|
1569
|
+
}
|
|
1570
|
+
generateUploadIdMultipart(key) {
|
|
1571
|
+
throw new Error("Method not implemented.");
|
|
1572
|
+
}
|
|
1573
|
+
listMultipartUploadsForBucket() {
|
|
1574
|
+
throw new Error("Method not implemented.");
|
|
1575
|
+
}
|
|
1576
|
+
listMultipartUploadsForKey(key, uploadId) {
|
|
1577
|
+
throw new Error("Method not implemented.");
|
|
1578
|
+
}
|
|
1579
|
+
uploadMultipart(key, file, partNumber, uploadId) {
|
|
1580
|
+
throw new Error("Method not implemented.");
|
|
1581
|
+
}
|
|
1582
|
+
completeMultipartUpload(key, uploadId) {
|
|
1583
|
+
throw new Error("Method not implemented.");
|
|
1584
|
+
}
|
|
1585
|
+
abortMultipartUpload(key, uploadId) {
|
|
1586
|
+
throw new Error("Method not implemented.");
|
|
1587
|
+
}
|
|
1588
|
+
getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
|
|
1589
|
+
throw new Error("Method not implemented.");
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
var FtpStorageService = class {
|
|
1593
|
+
constructor(bucketName, options) {
|
|
1594
|
+
this.bucketName = bucketName;
|
|
1595
|
+
this.options = options || {};
|
|
1596
|
+
this.client = new Client();
|
|
1597
|
+
}
|
|
1598
|
+
listAll(options) {
|
|
1599
|
+
throw new Error("Method not implemented.");
|
|
1600
|
+
}
|
|
1601
|
+
async initializeClient() {
|
|
1602
|
+
var _a, _b, _c, _d, _e;
|
|
1603
|
+
const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
|
|
1604
|
+
const port = parseInt(
|
|
1605
|
+
String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
|
|
1606
|
+
10
|
|
1607
|
+
);
|
|
1608
|
+
const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
|
|
1609
|
+
const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
|
|
1610
|
+
await this.client.access({
|
|
1611
|
+
host,
|
|
1612
|
+
port,
|
|
1613
|
+
user,
|
|
1614
|
+
password,
|
|
1615
|
+
secure: ((_e = this == null ? void 0 : this.options) == null ? void 0 : _e.secure) || false
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
async withClient(fn) {
|
|
1619
|
+
try {
|
|
1620
|
+
await this.initializeClient();
|
|
1621
|
+
return await fn();
|
|
1622
|
+
} finally {
|
|
1623
|
+
this.client.close();
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
async list(options) {
|
|
1627
|
+
return this.withClient(async () => {
|
|
1628
|
+
const prefix = options.prefix || "";
|
|
1629
|
+
const path = `${this.bucketName}/${prefix}`;
|
|
1630
|
+
try {
|
|
1631
|
+
const list = await this.client.list(path);
|
|
1632
|
+
const items = list.map(
|
|
1633
|
+
(item) => ({
|
|
1634
|
+
key: prefix + item.name,
|
|
1635
|
+
lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
|
|
1636
|
+
size: item.size,
|
|
1637
|
+
eTag: ""
|
|
1638
|
+
})
|
|
1639
|
+
);
|
|
1640
|
+
return {
|
|
1641
|
+
items,
|
|
1642
|
+
pagination: null,
|
|
1643
|
+
count: items.length
|
|
1644
|
+
};
|
|
1645
|
+
} catch (e) {
|
|
1646
|
+
return { items: [], pagination: null, count: 0 };
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
async getObject(key) {
|
|
1651
|
+
await this.initializeClient();
|
|
1652
|
+
const passThrough = new PassThrough();
|
|
1653
|
+
const path = `${this.bucketName}/${key}`;
|
|
1654
|
+
const stats = await this.client.size(path);
|
|
1655
|
+
this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
|
|
1656
|
+
const cleanup = () => {
|
|
1657
|
+
this.client.close();
|
|
1658
|
+
};
|
|
1659
|
+
passThrough.on("end", cleanup);
|
|
1660
|
+
passThrough.on("error", cleanup);
|
|
1661
|
+
return {
|
|
1662
|
+
body: passThrough,
|
|
1663
|
+
contentLength: stats,
|
|
1664
|
+
lastModified: /* @__PURE__ */ new Date(),
|
|
1665
|
+
metadata: {}
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
async upload(key, body) {
|
|
1669
|
+
return this.withClient(async () => {
|
|
1670
|
+
await this.client.cd("/");
|
|
1671
|
+
try {
|
|
1672
|
+
await this.client.cd(this.bucketName);
|
|
1673
|
+
} catch (e) {
|
|
1674
|
+
await this.client.send(`MKD ${this.bucketName}`);
|
|
1675
|
+
await this.client.cd(this.bucketName);
|
|
1676
|
+
}
|
|
1677
|
+
const parts = key.split("/");
|
|
1678
|
+
parts.pop();
|
|
1679
|
+
for (const part of parts) {
|
|
1680
|
+
if (!part)
|
|
1681
|
+
continue;
|
|
1682
|
+
try {
|
|
1683
|
+
await this.client.cd(part);
|
|
1684
|
+
} catch (e) {
|
|
1685
|
+
await this.client.send(`MKD ${part}`);
|
|
1686
|
+
await this.client.cd(part);
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
await this.client.cd("/");
|
|
1690
|
+
const fullPath = `${this.bucketName}/${key}`;
|
|
1691
|
+
const stream3 = body instanceof Readable ? body : Readable.from([body]);
|
|
1692
|
+
await this.client.uploadFrom(stream3, fullPath);
|
|
1693
|
+
return { key };
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
async delete(key) {
|
|
1697
|
+
return this.withClient(async () => {
|
|
1698
|
+
await this.client.remove(`${this.bucketName}/${key}`);
|
|
1699
|
+
return true;
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
async close() {
|
|
1703
|
+
this.client.close();
|
|
1704
|
+
}
|
|
1705
|
+
// Unsupported Operations
|
|
1706
|
+
async getDownloadUrl(_key, _expiresInMinutes) {
|
|
1707
|
+
throw new Error("FTP does not support pre-signed URLs");
|
|
1708
|
+
}
|
|
1709
|
+
async getUploadUrl(_key, _expiresInMinutes) {
|
|
1710
|
+
throw new Error("FTP does not support pre-signed URLs");
|
|
1711
|
+
}
|
|
1712
|
+
async getHeadObject(_key) {
|
|
1713
|
+
throw new Error("Operation not supported");
|
|
1714
|
+
}
|
|
1715
|
+
createUploadWriteStream(_key) {
|
|
1716
|
+
throw new Error("Operation not supported");
|
|
1717
|
+
}
|
|
1718
|
+
async getHeadBucket() {
|
|
1719
|
+
throw new Error("Operation not supported");
|
|
1720
|
+
}
|
|
1721
|
+
async generateUploadIdMultipart(_key) {
|
|
1722
|
+
throw new Error("Multipart upload is not supported");
|
|
1723
|
+
}
|
|
1724
|
+
async listMultipartUploadsForBucket() {
|
|
1725
|
+
throw new Error("Multipart upload is not supported");
|
|
1726
|
+
}
|
|
1727
|
+
async listMultipartUploadsForKey(_key, _uploadId) {
|
|
1728
|
+
throw new Error("Multipart upload is not supported");
|
|
1729
|
+
}
|
|
1730
|
+
async uploadMultipart(_key, _file, _partNumber, _uploadId) {
|
|
1731
|
+
throw new Error("Multipart upload is not supported");
|
|
1732
|
+
}
|
|
1733
|
+
async completeMultipartUpload(_key, _uploadId) {
|
|
1734
|
+
throw new Error("Multipart upload is not supported");
|
|
1735
|
+
}
|
|
1736
|
+
async abortMultipartUpload(_key, _uploadId) {
|
|
1737
|
+
throw new Error("Method not implemented.");
|
|
1738
|
+
}
|
|
1739
|
+
async getMultipartUploadPresignedUrl(_key, _uploadId, _partNumber, _expiresInMinutes) {
|
|
1740
|
+
throw new Error("Multipart upload is not supported");
|
|
1741
|
+
}
|
|
1742
|
+
};
|
|
1363
1743
|
|
|
1364
1744
|
// src/shared/utils/constants.ts
|
|
1365
1745
|
var OBJECT_STORAGE_SERVICE_TYPES = {
|
|
1366
1746
|
AWS_S3: "aws_s3",
|
|
1367
|
-
AZURE_BLOB_STORAGE: "azure_blob_storage"
|
|
1747
|
+
AZURE_BLOB_STORAGE: "azure_blob_storage",
|
|
1748
|
+
FTP: "ftp",
|
|
1749
|
+
SFTP: "sftp"
|
|
1368
1750
|
};
|
|
1369
1751
|
|
|
1370
1752
|
// src/services/objectStorageFactory.service.ts
|
|
@@ -1376,7 +1758,11 @@ var ObjectStorageFactory = class {
|
|
|
1376
1758
|
case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:
|
|
1377
1759
|
return new S3StorageService(bucketName, options);
|
|
1378
1760
|
case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:
|
|
1379
|
-
return new BlobStorageService(bucketName);
|
|
1761
|
+
return new BlobStorageService(bucketName, options);
|
|
1762
|
+
case OBJECT_STORAGE_SERVICE_TYPES.FTP:
|
|
1763
|
+
return new FtpStorageService(bucketName, options);
|
|
1764
|
+
case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
|
|
1765
|
+
return new SftpStorageService(bucketName, options);
|
|
1380
1766
|
default:
|
|
1381
1767
|
throw new Error(
|
|
1382
1768
|
`Unsupported object storage provider: ${provider}`
|
|
@@ -1402,11 +1788,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1402
1788
|
*
|
|
1403
1789
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1404
1790
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1791
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1405
1792
|
* @return {Promise<ListResponse>} A promise that resolves to the list of objects.
|
|
1406
1793
|
*/
|
|
1407
|
-
static async list(options, bucketName) {
|
|
1794
|
+
static async list(options, bucketName, objectStorageOptions) {
|
|
1408
1795
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1409
|
-
bucketName
|
|
1796
|
+
bucketName,
|
|
1797
|
+
objectStorageOptions
|
|
1410
1798
|
).then((instance) => instance.list(options));
|
|
1411
1799
|
}
|
|
1412
1800
|
/**
|
|
@@ -1414,11 +1802,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1414
1802
|
*
|
|
1415
1803
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1416
1804
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1805
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1417
1806
|
* @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
|
|
1418
1807
|
*/
|
|
1419
|
-
static async listAll(options, bucketName) {
|
|
1808
|
+
static async listAll(options, bucketName, objectStorageOptions) {
|
|
1420
1809
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1421
|
-
bucketName
|
|
1810
|
+
bucketName,
|
|
1811
|
+
objectStorageOptions
|
|
1422
1812
|
).then((instance) => instance.listAll(options));
|
|
1423
1813
|
}
|
|
1424
1814
|
/**
|
|
@@ -1426,21 +1816,27 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1426
1816
|
*
|
|
1427
1817
|
* @param {string} key - The key of the object to retrieve.
|
|
1428
1818
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1819
|
+
* @param {IGetObjectOptions} [options] - The options to apply to the get operation.
|
|
1820
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1429
1821
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
|
|
1430
1822
|
*/
|
|
1431
|
-
static async getObject(key, bucketName, options) {
|
|
1823
|
+
static async getObject(key, bucketName, options, objectStorageOptions) {
|
|
1432
1824
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1433
|
-
bucketName
|
|
1825
|
+
bucketName,
|
|
1826
|
+
objectStorageOptions
|
|
1434
1827
|
).then((instance) => instance.getObject(key, options));
|
|
1435
1828
|
}
|
|
1436
1829
|
/**
|
|
1437
1830
|
* Retrieves an object info (without file content) from the object storage service.
|
|
1438
1831
|
* @param key - The key of the object to retrieve.
|
|
1832
|
+
* @param bucketName - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1833
|
+
* @param objectStorageOptions - The options for the object storage service.
|
|
1439
1834
|
* @returns A promise that resolves to the info of the file.
|
|
1440
1835
|
*/
|
|
1441
|
-
static async getHeadObject(key, bucketName) {
|
|
1836
|
+
static async getHeadObject(key, bucketName, objectStorageOptions) {
|
|
1442
1837
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1443
|
-
bucketName
|
|
1838
|
+
bucketName,
|
|
1839
|
+
objectStorageOptions
|
|
1444
1840
|
).then((instance) => instance.getHeadObject(key));
|
|
1445
1841
|
}
|
|
1446
1842
|
/**
|
|
@@ -1449,11 +1845,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1449
1845
|
* @param {string} key - The key of the object for which to generate the signed URL.
|
|
1450
1846
|
* @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
|
|
1451
1847
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1848
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1452
1849
|
* @return {Promise<string>} A promise that resolves to the generated signed URL.
|
|
1453
1850
|
*/
|
|
1454
|
-
static async getDownloadUrl(key, expiresInMinutes, bucketName) {
|
|
1851
|
+
static async getDownloadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
|
|
1455
1852
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1456
|
-
bucketName
|
|
1853
|
+
bucketName,
|
|
1854
|
+
objectStorageOptions
|
|
1457
1855
|
).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
|
|
1458
1856
|
}
|
|
1459
1857
|
/**
|
|
@@ -1462,11 +1860,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1462
1860
|
* @param {string} key - The key of the object for which to generate the upload URL.
|
|
1463
1861
|
* @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
|
|
1464
1862
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1863
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1465
1864
|
* @return {Promise<string>} A promise that resolves to the generated upload URL.
|
|
1466
1865
|
*/
|
|
1467
|
-
static async getUploadUrl(key, expiresInMinutes, bucketName) {
|
|
1866
|
+
static async getUploadUrl(key, expiresInMinutes, bucketName, objectStorageOptions) {
|
|
1468
1867
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1469
|
-
bucketName
|
|
1868
|
+
bucketName,
|
|
1869
|
+
objectStorageOptions
|
|
1470
1870
|
).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
|
|
1471
1871
|
}
|
|
1472
1872
|
/**
|
|
@@ -1476,11 +1876,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1476
1876
|
* @param {FileContent} body - The content of the file to upload.
|
|
1477
1877
|
* @param {Object} [metadata] - Optional metadata to associate with the object.
|
|
1478
1878
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1879
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1479
1880
|
* @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
|
|
1480
1881
|
*/
|
|
1481
|
-
static async upload(key, body, metadata, bucketName) {
|
|
1882
|
+
static async upload(key, body, metadata, bucketName, objectStorageOptions) {
|
|
1482
1883
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1483
|
-
bucketName
|
|
1884
|
+
bucketName,
|
|
1885
|
+
objectStorageOptions
|
|
1484
1886
|
).then((instance) => instance.upload(key, body, metadata));
|
|
1485
1887
|
}
|
|
1486
1888
|
/**
|
|
@@ -1488,11 +1890,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1488
1890
|
*
|
|
1489
1891
|
* @param {string} key - The key of the object to create the upload write stream for.
|
|
1490
1892
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1893
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1491
1894
|
* @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
|
|
1492
1895
|
*/
|
|
1493
|
-
static async createUploadWriteStream(key, bucketName) {
|
|
1896
|
+
static async createUploadWriteStream(key, bucketName, objectStorageOptions) {
|
|
1494
1897
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1495
|
-
bucketName
|
|
1898
|
+
bucketName,
|
|
1899
|
+
objectStorageOptions
|
|
1496
1900
|
).then((instance) => instance.createUploadWriteStream(key));
|
|
1497
1901
|
}
|
|
1498
1902
|
/**
|
|
@@ -1500,11 +1904,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1500
1904
|
*
|
|
1501
1905
|
* @param {string | string[]} key - The key or array of keys of the objects to delete.
|
|
1502
1906
|
* @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.
|
|
1907
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1503
1908
|
* @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.
|
|
1504
1909
|
*/
|
|
1505
|
-
static async delete(key, bucketName) {
|
|
1910
|
+
static async delete(key, bucketName, objectStorageOptions) {
|
|
1506
1911
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1507
|
-
bucketName
|
|
1912
|
+
bucketName,
|
|
1913
|
+
objectStorageOptions
|
|
1508
1914
|
).then(async (instance) => {
|
|
1509
1915
|
if (Array.isArray(key)) {
|
|
1510
1916
|
const deleteBlobPromises = key.map(async (blobName) => {
|
|
@@ -1530,11 +1936,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1530
1936
|
* Retrieves the head bucket from the object storage service.
|
|
1531
1937
|
*
|
|
1532
1938
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1939
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1533
1940
|
* @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
|
|
1534
1941
|
*/
|
|
1535
|
-
static async getHeadBucket(bucketName) {
|
|
1942
|
+
static async getHeadBucket(bucketName, objectStorageOptions) {
|
|
1536
1943
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1537
|
-
bucketName
|
|
1944
|
+
bucketName,
|
|
1945
|
+
objectStorageOptions
|
|
1538
1946
|
).then((instance) => instance.getHeadBucket());
|
|
1539
1947
|
}
|
|
1540
1948
|
/**
|
|
@@ -1542,11 +1950,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1542
1950
|
*
|
|
1543
1951
|
* @param {string} key - The key of the object to upload.
|
|
1544
1952
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1953
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1545
1954
|
* @return {Promise<string>} A promise that resolves to the generated upload ID.
|
|
1546
1955
|
*/
|
|
1547
|
-
static async generateUploadIdMultipart(key, bucketName) {
|
|
1956
|
+
static async generateUploadIdMultipart(key, bucketName, objectStorageOptions) {
|
|
1548
1957
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1549
|
-
bucketName
|
|
1958
|
+
bucketName,
|
|
1959
|
+
objectStorageOptions
|
|
1550
1960
|
).then((instance) => instance.generateUploadIdMultipart(key));
|
|
1551
1961
|
}
|
|
1552
1962
|
/**
|
|
@@ -1555,11 +1965,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1555
1965
|
* @param {string} key - The key of the object to retrieve uploads for.
|
|
1556
1966
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1557
1967
|
* @param {string} [uploadId] - The upload ID to filter the results by.
|
|
1968
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1558
1969
|
* @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
|
|
1559
1970
|
*/
|
|
1560
|
-
static async listMultipartUploadsForKey(key, bucketName, uploadId) {
|
|
1971
|
+
static async listMultipartUploadsForKey(key, bucketName, uploadId, objectStorageOptions) {
|
|
1561
1972
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1562
|
-
bucketName
|
|
1973
|
+
bucketName,
|
|
1974
|
+
objectStorageOptions
|
|
1563
1975
|
).then(
|
|
1564
1976
|
(instance) => instance.listMultipartUploadsForKey(key, uploadId)
|
|
1565
1977
|
);
|
|
@@ -1568,11 +1980,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1568
1980
|
* Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
|
|
1569
1981
|
*
|
|
1570
1982
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1983
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1571
1984
|
* @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
|
|
1572
1985
|
*/
|
|
1573
|
-
static async listMultipartUploadsForBucket(bucketName) {
|
|
1986
|
+
static async listMultipartUploadsForBucket(bucketName, objectStorageOptions) {
|
|
1574
1987
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1575
|
-
bucketName
|
|
1988
|
+
bucketName,
|
|
1989
|
+
objectStorageOptions
|
|
1576
1990
|
).then((instance) => instance.listMultipartUploadsForBucket());
|
|
1577
1991
|
}
|
|
1578
1992
|
/**
|
|
@@ -1583,11 +1997,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1583
1997
|
* @param {number} partNumber - The number of the part being uploaded.
|
|
1584
1998
|
* @param {string} [uploadId] - The ID of the multipart upload.
|
|
1585
1999
|
* @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.
|
|
2000
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1586
2001
|
* @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
|
|
1587
2002
|
*/
|
|
1588
|
-
static async uploadMultipart(key, file, partNumber, uploadId, bucketName) {
|
|
2003
|
+
static async uploadMultipart(key, file, partNumber, uploadId, bucketName, objectStorageOptions) {
|
|
1589
2004
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1590
|
-
bucketName
|
|
2005
|
+
bucketName,
|
|
2006
|
+
objectStorageOptions
|
|
1591
2007
|
).then(
|
|
1592
2008
|
(instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
|
|
1593
2009
|
);
|
|
@@ -1598,11 +2014,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1598
2014
|
* @param {string} key - The key of the object to complete the multipart upload for.
|
|
1599
2015
|
* @param {string} uploadId - The ID of the multipart upload to complete.
|
|
1600
2016
|
* @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.
|
|
2017
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1601
2018
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
|
|
1602
2019
|
*/
|
|
1603
|
-
static async completeMultipartUpload(key, uploadId, bucketName) {
|
|
2020
|
+
static async completeMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
|
|
1604
2021
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1605
|
-
bucketName
|
|
2022
|
+
bucketName,
|
|
2023
|
+
objectStorageOptions
|
|
1606
2024
|
).then((instance) => instance.completeMultipartUpload(key, uploadId));
|
|
1607
2025
|
}
|
|
1608
2026
|
/**
|
|
@@ -1611,11 +2029,13 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1611
2029
|
* @param {string} key - The key of the object to abort the multipart upload for.
|
|
1612
2030
|
* @param {string} uploadId - The ID of the multipart upload to abort.
|
|
1613
2031
|
* @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.
|
|
2032
|
+
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1614
2033
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
|
|
1615
2034
|
*/
|
|
1616
|
-
static async abortMultipartUpload(key, uploadId, bucketName) {
|
|
2035
|
+
static async abortMultipartUpload(key, uploadId, bucketName, objectStorageOptions) {
|
|
1617
2036
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1618
|
-
bucketName
|
|
2037
|
+
bucketName,
|
|
2038
|
+
objectStorageOptions
|
|
1619
2039
|
).then((instance) => instance.abortMultipartUpload(key, uploadId));
|
|
1620
2040
|
}
|
|
1621
2041
|
/**
|