@qrvey/object-storage 0.0.10-beta.3 → 0.0.11-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 +401 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +6 -2
- package/dist/esm/index.mjs +402 -8
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +6 -2
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -5,6 +5,8 @@ var storageBlob = require('@azure/storage-blob');
|
|
|
5
5
|
var clientS3 = require('@aws-sdk/client-s3');
|
|
6
6
|
var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
|
|
7
7
|
var libStorage = require('@aws-sdk/lib-storage');
|
|
8
|
+
var http = require('http');
|
|
9
|
+
var https = require('https');
|
|
8
10
|
|
|
9
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
12
|
|
|
@@ -188,16 +190,28 @@ var BlobStorageService = class {
|
|
|
188
190
|
* Retrieves an object from the blob storage service.
|
|
189
191
|
*
|
|
190
192
|
* @param {string} blobName - The name of the blob to retrieve.
|
|
193
|
+
* @param {Object} [options] - The options that you can pass to the library.
|
|
191
194
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the object data, including the body, metadata, content type, and content length, or rejects with an error if there was an issue.
|
|
192
195
|
*/
|
|
193
|
-
async getObject(blobName) {
|
|
196
|
+
async getObject(blobName, options) {
|
|
194
197
|
var _a;
|
|
195
198
|
try {
|
|
199
|
+
let downloadBlockBlobResponse;
|
|
196
200
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
197
201
|
this.containerName
|
|
198
202
|
);
|
|
199
203
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
200
|
-
const
|
|
204
|
+
const expression = (options == null ? void 0 : options.range) || "";
|
|
205
|
+
const matches = expression.match(/\d+/g);
|
|
206
|
+
if (expression && (matches == null ? void 0 : matches.length)) {
|
|
207
|
+
const [start, end] = matches.map(Number);
|
|
208
|
+
downloadBlockBlobResponse = await blockBlobClient.download(
|
|
209
|
+
start,
|
|
210
|
+
end
|
|
211
|
+
);
|
|
212
|
+
} else {
|
|
213
|
+
downloadBlockBlobResponse = await blockBlobClient.download(0);
|
|
214
|
+
}
|
|
201
215
|
return {
|
|
202
216
|
body: downloadBlockBlobResponse.readableStreamBody,
|
|
203
217
|
metadata: downloadBlockBlobResponse.metadata,
|
|
@@ -502,7 +516,7 @@ var BlobStorageService = class {
|
|
|
502
516
|
);
|
|
503
517
|
const blobClient = containerClient.getBlockBlobClient(blobName);
|
|
504
518
|
const listResponse = await blobClient.getBlockList("all");
|
|
505
|
-
const parts = ((_a = listResponse == null ? void 0 : listResponse.
|
|
519
|
+
const parts = ((_a = listResponse == null ? void 0 : listResponse.uncommittedBlocks) == null ? void 0 : _a.map((block, index) => ({
|
|
506
520
|
PartNumber: index + 1,
|
|
507
521
|
LastModified: /* @__PURE__ */ new Date(),
|
|
508
522
|
// Azure Blob Storage doesn't provide the last modified date for individual parts
|
|
@@ -619,12 +633,392 @@ function s3ObjectToObjectResponse(s3Object) {
|
|
|
619
633
|
lastModified: s3Object.LastModified
|
|
620
634
|
};
|
|
621
635
|
}
|
|
636
|
+
|
|
637
|
+
// ../../node_modules/@smithy/types/dist-es/auth/auth.js
|
|
638
|
+
var HttpAuthLocation;
|
|
639
|
+
(function(HttpAuthLocation2) {
|
|
640
|
+
HttpAuthLocation2["HEADER"] = "header";
|
|
641
|
+
HttpAuthLocation2["QUERY"] = "query";
|
|
642
|
+
})(HttpAuthLocation || (HttpAuthLocation = {}));
|
|
643
|
+
|
|
644
|
+
// ../../node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
|
|
645
|
+
var HttpApiKeyAuthLocation;
|
|
646
|
+
(function(HttpApiKeyAuthLocation2) {
|
|
647
|
+
HttpApiKeyAuthLocation2["HEADER"] = "header";
|
|
648
|
+
HttpApiKeyAuthLocation2["QUERY"] = "query";
|
|
649
|
+
})(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
|
|
650
|
+
|
|
651
|
+
// ../../node_modules/@smithy/types/dist-es/endpoint.js
|
|
652
|
+
var EndpointURLScheme;
|
|
653
|
+
(function(EndpointURLScheme2) {
|
|
654
|
+
EndpointURLScheme2["HTTP"] = "http";
|
|
655
|
+
EndpointURLScheme2["HTTPS"] = "https";
|
|
656
|
+
})(EndpointURLScheme || (EndpointURLScheme = {}));
|
|
657
|
+
|
|
658
|
+
// ../../node_modules/@smithy/types/dist-es/extensions/checksum.js
|
|
659
|
+
var AlgorithmId;
|
|
660
|
+
(function(AlgorithmId2) {
|
|
661
|
+
AlgorithmId2["MD5"] = "md5";
|
|
662
|
+
AlgorithmId2["CRC32"] = "crc32";
|
|
663
|
+
AlgorithmId2["CRC32C"] = "crc32c";
|
|
664
|
+
AlgorithmId2["SHA1"] = "sha1";
|
|
665
|
+
AlgorithmId2["SHA256"] = "sha256";
|
|
666
|
+
})(AlgorithmId || (AlgorithmId = {}));
|
|
667
|
+
|
|
668
|
+
// ../../node_modules/@smithy/types/dist-es/http.js
|
|
669
|
+
var FieldPosition;
|
|
670
|
+
(function(FieldPosition2) {
|
|
671
|
+
FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
|
|
672
|
+
FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
|
|
673
|
+
})(FieldPosition || (FieldPosition = {}));
|
|
674
|
+
|
|
675
|
+
// ../../node_modules/@smithy/types/dist-es/profile.js
|
|
676
|
+
var IniSectionType;
|
|
677
|
+
(function(IniSectionType2) {
|
|
678
|
+
IniSectionType2["PROFILE"] = "profile";
|
|
679
|
+
IniSectionType2["SSO_SESSION"] = "sso-session";
|
|
680
|
+
IniSectionType2["SERVICES"] = "services";
|
|
681
|
+
})(IniSectionType || (IniSectionType = {}));
|
|
682
|
+
|
|
683
|
+
// ../../node_modules/@smithy/types/dist-es/transfer.js
|
|
684
|
+
var RequestHandlerProtocol;
|
|
685
|
+
(function(RequestHandlerProtocol2) {
|
|
686
|
+
RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
|
|
687
|
+
RequestHandlerProtocol2["HTTP_1_0"] = "http/1.0";
|
|
688
|
+
RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
|
|
689
|
+
})(RequestHandlerProtocol || (RequestHandlerProtocol = {}));
|
|
690
|
+
|
|
691
|
+
// ../../node_modules/@smithy/protocol-http/dist-es/httpResponse.js
|
|
692
|
+
var HttpResponse = class {
|
|
693
|
+
constructor(options) {
|
|
694
|
+
this.statusCode = options.statusCode;
|
|
695
|
+
this.reason = options.reason;
|
|
696
|
+
this.headers = options.headers || {};
|
|
697
|
+
this.body = options.body;
|
|
698
|
+
}
|
|
699
|
+
static isInstance(response) {
|
|
700
|
+
if (!response)
|
|
701
|
+
return false;
|
|
702
|
+
const resp = response;
|
|
703
|
+
return typeof resp.statusCode === "number" && typeof resp.headers === "object";
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
// ../../node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
|
|
708
|
+
var escapeUri = (uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode);
|
|
709
|
+
var hexEncode = (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
|
|
710
|
+
|
|
711
|
+
// ../../node_modules/@smithy/querystring-builder/dist-es/index.js
|
|
712
|
+
function buildQueryString(query) {
|
|
713
|
+
const parts = [];
|
|
714
|
+
for (let key of Object.keys(query).sort()) {
|
|
715
|
+
const value = query[key];
|
|
716
|
+
key = escapeUri(key);
|
|
717
|
+
if (Array.isArray(value)) {
|
|
718
|
+
for (let i = 0, iLen = value.length; i < iLen; i++) {
|
|
719
|
+
parts.push(`${key}=${escapeUri(value[i])}`);
|
|
720
|
+
}
|
|
721
|
+
} else {
|
|
722
|
+
let qsEntry = key;
|
|
723
|
+
if (value || typeof value === "string") {
|
|
724
|
+
qsEntry += `=${escapeUri(value)}`;
|
|
725
|
+
}
|
|
726
|
+
parts.push(qsEntry);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return parts.join("&");
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/constants.js
|
|
733
|
+
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
734
|
+
|
|
735
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
|
|
736
|
+
var getTransformedHeaders = (headers) => {
|
|
737
|
+
const transformedHeaders = {};
|
|
738
|
+
for (const name of Object.keys(headers)) {
|
|
739
|
+
const headerValues = headers[name];
|
|
740
|
+
transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
|
|
741
|
+
}
|
|
742
|
+
return transformedHeaders;
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
|
|
746
|
+
var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
747
|
+
if (!timeoutInMs) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
const timeoutId = setTimeout(() => {
|
|
751
|
+
request.destroy();
|
|
752
|
+
reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
|
|
753
|
+
name: "TimeoutError"
|
|
754
|
+
}));
|
|
755
|
+
}, timeoutInMs);
|
|
756
|
+
request.on("socket", (socket) => {
|
|
757
|
+
if (socket.connecting) {
|
|
758
|
+
socket.on("connect", () => {
|
|
759
|
+
clearTimeout(timeoutId);
|
|
760
|
+
});
|
|
761
|
+
} else {
|
|
762
|
+
clearTimeout(timeoutId);
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
|
|
768
|
+
var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }) => {
|
|
769
|
+
if (keepAlive !== true) {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
request.on("socket", (socket) => {
|
|
773
|
+
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
774
|
+
});
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
|
|
778
|
+
var setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
779
|
+
request.setTimeout(timeoutInMs, () => {
|
|
780
|
+
request.destroy();
|
|
781
|
+
reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
|
|
782
|
+
});
|
|
783
|
+
};
|
|
784
|
+
var MIN_WAIT_TIME = 1e3;
|
|
785
|
+
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
|
|
786
|
+
var _a;
|
|
787
|
+
const headers = (_a = request.headers) != null ? _a : {};
|
|
788
|
+
const expect = headers["Expect"] || headers["expect"];
|
|
789
|
+
let timeoutId = -1;
|
|
790
|
+
let hasError = false;
|
|
791
|
+
if (expect === "100-continue") {
|
|
792
|
+
await Promise.race([
|
|
793
|
+
new Promise((resolve) => {
|
|
794
|
+
timeoutId = Number(setTimeout(resolve, Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
795
|
+
}),
|
|
796
|
+
new Promise((resolve) => {
|
|
797
|
+
httpRequest.on("continue", () => {
|
|
798
|
+
clearTimeout(timeoutId);
|
|
799
|
+
resolve();
|
|
800
|
+
});
|
|
801
|
+
httpRequest.on("error", () => {
|
|
802
|
+
hasError = true;
|
|
803
|
+
clearTimeout(timeoutId);
|
|
804
|
+
resolve();
|
|
805
|
+
});
|
|
806
|
+
})
|
|
807
|
+
]);
|
|
808
|
+
}
|
|
809
|
+
if (!hasError) {
|
|
810
|
+
writeBody(httpRequest, request.body);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
function writeBody(httpRequest, body) {
|
|
814
|
+
if (body instanceof stream.Readable) {
|
|
815
|
+
body.pipe(httpRequest);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
if (body) {
|
|
819
|
+
if (Buffer.isBuffer(body) || typeof body === "string") {
|
|
820
|
+
httpRequest.end(body);
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
const uint8 = body;
|
|
824
|
+
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
|
|
825
|
+
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
httpRequest.end(Buffer.from(body));
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
httpRequest.end();
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// ../../node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
|
|
835
|
+
var NodeHttpHandler = class _NodeHttpHandler {
|
|
836
|
+
static create(instanceOrOptions) {
|
|
837
|
+
if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
|
|
838
|
+
return instanceOrOptions;
|
|
839
|
+
}
|
|
840
|
+
return new _NodeHttpHandler(instanceOrOptions);
|
|
841
|
+
}
|
|
842
|
+
static checkSocketUsage(agent, socketWarningTimestamp) {
|
|
843
|
+
var _a, _b, _c, _d;
|
|
844
|
+
const { sockets, requests, maxSockets } = agent;
|
|
845
|
+
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
846
|
+
return socketWarningTimestamp;
|
|
847
|
+
}
|
|
848
|
+
const interval = 15e3;
|
|
849
|
+
if (Date.now() - interval < socketWarningTimestamp) {
|
|
850
|
+
return socketWarningTimestamp;
|
|
851
|
+
}
|
|
852
|
+
if (sockets && requests) {
|
|
853
|
+
for (const origin in sockets) {
|
|
854
|
+
const socketsInUse = (_b = (_a = sockets[origin]) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
855
|
+
const requestsEnqueued = (_d = (_c = requests[origin]) == null ? void 0 : _c.length) != null ? _d : 0;
|
|
856
|
+
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
857
|
+
console.warn("@smithy/node-http-handler:WARN", `socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.`, "See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html", "or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.");
|
|
858
|
+
return Date.now();
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return socketWarningTimestamp;
|
|
863
|
+
}
|
|
864
|
+
constructor(options) {
|
|
865
|
+
this.socketWarningTimestamp = 0;
|
|
866
|
+
this.metadata = { handlerProtocol: "http/1.1" };
|
|
867
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
868
|
+
if (typeof options === "function") {
|
|
869
|
+
options().then((_options) => {
|
|
870
|
+
resolve(this.resolveDefaultConfig(_options));
|
|
871
|
+
}).catch(reject);
|
|
872
|
+
} else {
|
|
873
|
+
resolve(this.resolveDefaultConfig(options));
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
resolveDefaultConfig(options) {
|
|
878
|
+
const { requestTimeout, connectionTimeout, socketTimeout, httpAgent, httpsAgent } = options || {};
|
|
879
|
+
const keepAlive = true;
|
|
880
|
+
const maxSockets = 50;
|
|
881
|
+
return {
|
|
882
|
+
connectionTimeout,
|
|
883
|
+
requestTimeout: requestTimeout != null ? requestTimeout : socketTimeout,
|
|
884
|
+
httpAgent: (() => {
|
|
885
|
+
if (httpAgent instanceof http.Agent || typeof (httpAgent == null ? void 0 : httpAgent.destroy) === "function") {
|
|
886
|
+
return httpAgent;
|
|
887
|
+
}
|
|
888
|
+
return new http.Agent(__spreadValues({ keepAlive, maxSockets }, httpAgent));
|
|
889
|
+
})(),
|
|
890
|
+
httpsAgent: (() => {
|
|
891
|
+
if (httpsAgent instanceof https.Agent || typeof (httpsAgent == null ? void 0 : httpsAgent.destroy) === "function") {
|
|
892
|
+
return httpsAgent;
|
|
893
|
+
}
|
|
894
|
+
return new https.Agent(__spreadValues({ keepAlive, maxSockets }, httpsAgent));
|
|
895
|
+
})()
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
destroy() {
|
|
899
|
+
var _a, _b, _c, _d;
|
|
900
|
+
(_b = (_a = this.config) == null ? void 0 : _a.httpAgent) == null ? void 0 : _b.destroy();
|
|
901
|
+
(_d = (_c = this.config) == null ? void 0 : _c.httpsAgent) == null ? void 0 : _d.destroy();
|
|
902
|
+
}
|
|
903
|
+
async handle(request, { abortSignal } = {}) {
|
|
904
|
+
if (!this.config) {
|
|
905
|
+
this.config = await this.configProvider;
|
|
906
|
+
}
|
|
907
|
+
let socketCheckTimeoutId;
|
|
908
|
+
return new Promise((_resolve, _reject) => {
|
|
909
|
+
var _a, _b, _c, _d, _e;
|
|
910
|
+
let writeRequestBodyPromise = void 0;
|
|
911
|
+
const resolve = async (arg) => {
|
|
912
|
+
await writeRequestBodyPromise;
|
|
913
|
+
clearTimeout(socketCheckTimeoutId);
|
|
914
|
+
_resolve(arg);
|
|
915
|
+
};
|
|
916
|
+
const reject = async (arg) => {
|
|
917
|
+
await writeRequestBodyPromise;
|
|
918
|
+
_reject(arg);
|
|
919
|
+
};
|
|
920
|
+
if (!this.config) {
|
|
921
|
+
throw new Error("Node HTTP request handler config is not resolved");
|
|
922
|
+
}
|
|
923
|
+
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
924
|
+
const abortError = new Error("Request aborted");
|
|
925
|
+
abortError.name = "AbortError";
|
|
926
|
+
reject(abortError);
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
const isSSL = request.protocol === "https:";
|
|
930
|
+
const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
|
|
931
|
+
socketCheckTimeoutId = setTimeout(() => {
|
|
932
|
+
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp);
|
|
933
|
+
}, (_c = this.config.socketAcquisitionWarningTimeout) != null ? _c : ((_a = this.config.requestTimeout) != null ? _a : 2e3) + ((_b = this.config.connectionTimeout) != null ? _b : 1e3));
|
|
934
|
+
const queryString = buildQueryString(request.query || {});
|
|
935
|
+
let auth = void 0;
|
|
936
|
+
if (request.username != null || request.password != null) {
|
|
937
|
+
const username = (_d = request.username) != null ? _d : "";
|
|
938
|
+
const password = (_e = request.password) != null ? _e : "";
|
|
939
|
+
auth = `${username}:${password}`;
|
|
940
|
+
}
|
|
941
|
+
let path = request.path;
|
|
942
|
+
if (queryString) {
|
|
943
|
+
path += `?${queryString}`;
|
|
944
|
+
}
|
|
945
|
+
if (request.fragment) {
|
|
946
|
+
path += `#${request.fragment}`;
|
|
947
|
+
}
|
|
948
|
+
const nodeHttpsOptions = {
|
|
949
|
+
headers: request.headers,
|
|
950
|
+
host: request.hostname,
|
|
951
|
+
method: request.method,
|
|
952
|
+
path,
|
|
953
|
+
port: request.port,
|
|
954
|
+
agent,
|
|
955
|
+
auth
|
|
956
|
+
};
|
|
957
|
+
const requestFunc = isSSL ? https.request : http.request;
|
|
958
|
+
const req = requestFunc(nodeHttpsOptions, (res) => {
|
|
959
|
+
const httpResponse = new HttpResponse({
|
|
960
|
+
statusCode: res.statusCode || -1,
|
|
961
|
+
reason: res.statusMessage,
|
|
962
|
+
headers: getTransformedHeaders(res.headers),
|
|
963
|
+
body: res
|
|
964
|
+
});
|
|
965
|
+
resolve({ response: httpResponse });
|
|
966
|
+
});
|
|
967
|
+
req.on("error", (err) => {
|
|
968
|
+
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
969
|
+
reject(Object.assign(err, { name: "TimeoutError" }));
|
|
970
|
+
} else {
|
|
971
|
+
reject(err);
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
setConnectionTimeout(req, reject, this.config.connectionTimeout);
|
|
975
|
+
setSocketTimeout(req, reject, this.config.requestTimeout);
|
|
976
|
+
if (abortSignal) {
|
|
977
|
+
abortSignal.onabort = () => {
|
|
978
|
+
req.abort();
|
|
979
|
+
const abortError = new Error("Request aborted");
|
|
980
|
+
abortError.name = "AbortError";
|
|
981
|
+
reject(abortError);
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
const httpAgent = nodeHttpsOptions.agent;
|
|
985
|
+
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
986
|
+
setSocketKeepAlive(req, {
|
|
987
|
+
keepAlive: httpAgent.keepAlive,
|
|
988
|
+
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout).catch(_reject);
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
updateHttpClientConfig(key, value) {
|
|
995
|
+
this.config = void 0;
|
|
996
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
997
|
+
return __spreadProps(__spreadValues({}, config), {
|
|
998
|
+
[key]: value
|
|
999
|
+
});
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
httpHandlerConfigs() {
|
|
1003
|
+
var _a;
|
|
1004
|
+
return (_a = this.config) != null ? _a : {};
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
// src/services/storage/s3/s3Storage.service.ts
|
|
622
1009
|
var S3StorageService = class {
|
|
623
1010
|
constructor(bucketName, options) {
|
|
1011
|
+
this.httpHandler = new NodeHttpHandler({
|
|
1012
|
+
socketTimeout: 6e4
|
|
1013
|
+
});
|
|
624
1014
|
this.s3Client = new clientS3.S3Client({
|
|
625
|
-
region: process.env.AWS_DEFAULT_REGION
|
|
1015
|
+
region: process.env.AWS_DEFAULT_REGION,
|
|
1016
|
+
requestHandler: this.httpHandler
|
|
1017
|
+
});
|
|
1018
|
+
this.s3 = new clientS3.S3({
|
|
1019
|
+
region: process.env.AWS_DEFAULT_REGION,
|
|
1020
|
+
requestHandler: this.httpHandler
|
|
626
1021
|
});
|
|
627
|
-
this.s3 = new clientS3.S3({ region: process.env.AWS_DEFAULT_REGION });
|
|
628
1022
|
var _a, _b, _c, _d;
|
|
629
1023
|
this.bucketName = bucketName;
|
|
630
1024
|
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)) {
|
|
@@ -1035,10 +1429,10 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1035
1429
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1036
1430
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
|
|
1037
1431
|
*/
|
|
1038
|
-
static async getObject(key, bucketName) {
|
|
1432
|
+
static async getObject(key, bucketName, options) {
|
|
1039
1433
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1040
1434
|
bucketName
|
|
1041
|
-
).then((instance) => instance.getObject(key));
|
|
1435
|
+
).then((instance) => instance.getObject(key, options));
|
|
1042
1436
|
}
|
|
1043
1437
|
/**
|
|
1044
1438
|
* Retrieves an object info (without file content) from the object storage service.
|