@aws-amplify/storage 5.6.3 → 5.6.4-api-v6.13
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/lib/AwsClients/S3/abortMultipartUpload.d.ts +21 -0
- package/lib/AwsClients/S3/abortMultipartUpload.js +85 -0
- package/lib/AwsClients/S3/base.d.ts +54 -0
- package/lib/AwsClients/S3/base.js +75 -0
- package/lib/AwsClients/S3/completeMultipartUpload.d.ts +20 -0
- package/lib/AwsClients/S3/completeMultipartUpload.js +162 -0
- package/lib/AwsClients/S3/copyObject.d.ts +24 -0
- package/lib/AwsClients/S3/copyObject.js +98 -0
- package/lib/AwsClients/S3/createMultipartUpload.d.ts +21 -0
- package/lib/AwsClients/S3/createMultipartUpload.js +95 -0
- package/lib/AwsClients/S3/deleteObject.d.ts +20 -0
- package/lib/AwsClients/S3/deleteObject.js +86 -0
- package/lib/AwsClients/S3/getObject.d.ts +27 -0
- package/lib/AwsClients/S3/getObject.js +216 -0
- package/lib/AwsClients/S3/headObject.d.ts +20 -0
- package/lib/AwsClients/S3/headObject.js +96 -0
- package/lib/AwsClients/S3/index.d.ts +13 -0
- package/lib/AwsClients/S3/index.js +30 -0
- package/lib/AwsClients/S3/index.native.d.ts +14 -0
- package/lib/AwsClients/S3/index.native.js +31 -0
- package/lib/AwsClients/S3/listObjectsV2.d.ts +20 -0
- package/lib/AwsClients/S3/listObjectsV2.js +146 -0
- package/lib/AwsClients/S3/listParts.d.ts +20 -0
- package/lib/AwsClients/S3/listParts.js +110 -0
- package/lib/AwsClients/S3/putObject.d.ts +23 -0
- package/lib/AwsClients/S3/putObject.js +93 -0
- package/lib/AwsClients/S3/runtime/base64/index.browser.d.ts +2 -0
- package/lib/AwsClients/S3/runtime/base64/index.browser.js +20 -0
- package/lib/AwsClients/S3/runtime/base64/index.native.d.ts +2 -0
- package/lib/AwsClients/S3/runtime/base64/index.native.js +17 -0
- package/lib/AwsClients/S3/runtime/constants.d.ts +9 -0
- package/lib/AwsClients/S3/runtime/constants.js +14 -0
- package/lib/AwsClients/S3/runtime/contentSha256middleware.d.ts +9 -0
- package/lib/AwsClients/S3/runtime/contentSha256middleware.js +70 -0
- package/lib/AwsClients/S3/runtime/index.browser.d.ts +5 -0
- package/lib/AwsClients/S3/runtime/index.browser.js +20 -0
- package/lib/AwsClients/S3/runtime/index.d.ts +5 -0
- package/lib/AwsClients/S3/runtime/index.js +21 -0
- package/lib/AwsClients/S3/runtime/index.native.d.ts +5 -0
- package/lib/AwsClients/S3/runtime/index.native.js +20 -0
- package/lib/AwsClients/S3/runtime/s3TransferHandler/fetch.d.ts +8 -0
- package/lib/AwsClients/S3/runtime/s3TransferHandler/fetch.js +15 -0
- package/lib/AwsClients/S3/runtime/s3TransferHandler/xhr.d.ts +8 -0
- package/lib/AwsClients/S3/runtime/s3TransferHandler/xhr.js +21 -0
- package/lib/AwsClients/S3/runtime/xhrTransferHandler.d.ts +22 -0
- package/lib/AwsClients/S3/runtime/xhrTransferHandler.js +201 -0
- package/lib/AwsClients/S3/runtime/xmlParser/dom.d.ts +8 -0
- package/lib/AwsClients/S3/runtime/xmlParser/dom.js +92 -0
- package/lib/AwsClients/S3/runtime/xmlParser/pureJs.d.ts +10 -0
- package/lib/AwsClients/S3/runtime/xmlParser/pureJs.js +57 -0
- package/lib/AwsClients/S3/types.d.ts +2857 -0
- package/lib/AwsClients/S3/types.js +4 -0
- package/lib/AwsClients/S3/uploadPart.d.ts +20 -0
- package/lib/AwsClients/S3/uploadPart.js +96 -0
- package/lib/AwsClients/S3/utils/deserializeHelpers.d.ts +78 -0
- package/lib/AwsClients/S3/utils/deserializeHelpers.js +153 -0
- package/lib/AwsClients/S3/utils/index.d.ts +5 -0
- package/lib/AwsClients/S3/utils/index.js +30 -0
- package/lib/AwsClients/S3/utils/parsePayload.d.ts +3 -0
- package/lib/AwsClients/S3/utils/parsePayload.js +96 -0
- package/lib/AwsClients/S3/utils/serializeHelpers.d.ts +42 -0
- package/lib/AwsClients/S3/utils/serializeHelpers.js +183 -0
- package/lib/Storage.d.ts +5 -5
- package/lib/Storage.js +60 -31
- package/lib/common/S3ClientUtils.d.ts +24 -15
- package/lib/common/S3ClientUtils.js +83 -95
- package/lib/common/StorageConstants.d.ts +0 -1
- package/lib/common/StorageConstants.js +3 -2
- package/lib/common/StorageErrorStrings.js +3 -1
- package/lib/common/StorageUtils.js +12 -6
- package/lib/index.js +19 -4
- package/lib/providers/AWSS3Provider.d.ts +4 -8
- package/lib/providers/AWSS3Provider.js +210 -139
- package/lib/providers/AWSS3ProviderManagedUpload.d.ts +7 -7
- package/lib/providers/AWSS3ProviderManagedUpload.js +184 -98
- package/lib/providers/AWSS3UploadTask.d.ts +8 -8
- package/lib/providers/AWSS3UploadTask.js +226 -129
- package/lib/providers/index.js +4 -2
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/AWSS3Provider.d.ts +62 -62
- package/lib/types/AWSS3Provider.js +0 -1
- package/lib/types/Provider.d.ts +1 -1
- package/lib/types/Provider.js +2 -1
- package/lib/types/Storage.d.ts +23 -23
- package/lib/types/Storage.js +0 -1
- package/lib/types/index.js +17 -1
- package/lib-esm/AwsClients/S3/abortMultipartUpload.d.ts +21 -0
- package/lib-esm/AwsClients/S3/abortMultipartUpload.js +82 -0
- package/lib-esm/AwsClients/S3/base.d.ts +54 -0
- package/lib-esm/AwsClients/S3/base.js +71 -0
- package/lib-esm/AwsClients/S3/completeMultipartUpload.d.ts +20 -0
- package/lib-esm/AwsClients/S3/completeMultipartUpload.js +159 -0
- package/lib-esm/AwsClients/S3/copyObject.d.ts +24 -0
- package/lib-esm/AwsClients/S3/copyObject.js +95 -0
- package/lib-esm/AwsClients/S3/createMultipartUpload.d.ts +21 -0
- package/lib-esm/AwsClients/S3/createMultipartUpload.js +92 -0
- package/lib-esm/AwsClients/S3/deleteObject.d.ts +20 -0
- package/lib-esm/AwsClients/S3/deleteObject.js +83 -0
- package/lib-esm/AwsClients/S3/getObject.d.ts +27 -0
- package/lib-esm/AwsClients/S3/getObject.js +212 -0
- package/lib-esm/AwsClients/S3/headObject.d.ts +20 -0
- package/lib-esm/AwsClients/S3/headObject.js +93 -0
- package/lib-esm/AwsClients/S3/index.d.ts +13 -0
- package/lib-esm/AwsClients/S3/index.js +14 -0
- package/lib-esm/AwsClients/S3/index.native.d.ts +14 -0
- package/lib-esm/AwsClients/S3/index.native.js +15 -0
- package/lib-esm/AwsClients/S3/listObjectsV2.d.ts +20 -0
- package/lib-esm/AwsClients/S3/listObjectsV2.js +143 -0
- package/lib-esm/AwsClients/S3/listParts.d.ts +20 -0
- package/lib-esm/AwsClients/S3/listParts.js +107 -0
- package/lib-esm/AwsClients/S3/putObject.d.ts +23 -0
- package/lib-esm/AwsClients/S3/putObject.js +90 -0
- package/lib-esm/AwsClients/S3/runtime/base64/index.browser.d.ts +2 -0
- package/lib-esm/AwsClients/S3/runtime/base64/index.browser.js +15 -0
- package/lib-esm/AwsClients/S3/runtime/base64/index.native.d.ts +2 -0
- package/lib-esm/AwsClients/S3/runtime/base64/index.native.js +12 -0
- package/lib-esm/AwsClients/S3/runtime/constants.d.ts +9 -0
- package/lib-esm/AwsClients/S3/runtime/constants.js +11 -0
- package/lib-esm/AwsClients/S3/runtime/contentSha256middleware.d.ts +9 -0
- package/lib-esm/AwsClients/S3/runtime/contentSha256middleware.js +66 -0
- package/lib-esm/AwsClients/S3/runtime/index.browser.d.ts +5 -0
- package/lib-esm/AwsClients/S3/runtime/index.browser.js +8 -0
- package/lib-esm/AwsClients/S3/runtime/index.d.ts +5 -0
- package/lib-esm/AwsClients/S3/runtime/index.js +9 -0
- package/lib-esm/AwsClients/S3/runtime/index.native.d.ts +5 -0
- package/lib-esm/AwsClients/S3/runtime/index.native.js +8 -0
- package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/fetch.d.ts +8 -0
- package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/fetch.js +12 -0
- package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/xhr.d.ts +8 -0
- package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/xhr.js +18 -0
- package/lib-esm/AwsClients/S3/runtime/xhrTransferHandler.d.ts +22 -0
- package/lib-esm/AwsClients/S3/runtime/xhrTransferHandler.js +196 -0
- package/lib-esm/AwsClients/S3/runtime/xmlParser/dom.d.ts +8 -0
- package/lib-esm/AwsClients/S3/runtime/xmlParser/dom.js +89 -0
- package/lib-esm/AwsClients/S3/runtime/xmlParser/pureJs.d.ts +10 -0
- package/lib-esm/AwsClients/S3/runtime/xmlParser/pureJs.js +54 -0
- package/lib-esm/AwsClients/S3/types.d.ts +2857 -0
- package/lib-esm/AwsClients/S3/types.js +3 -0
- package/lib-esm/AwsClients/S3/uploadPart.d.ts +20 -0
- package/lib-esm/AwsClients/S3/uploadPart.js +93 -0
- package/lib-esm/AwsClients/S3/utils/deserializeHelpers.d.ts +78 -0
- package/lib-esm/AwsClients/S3/utils/deserializeHelpers.js +144 -0
- package/lib-esm/AwsClients/S3/utils/index.d.ts +5 -0
- package/lib-esm/AwsClients/S3/utils/index.js +7 -0
- package/lib-esm/AwsClients/S3/utils/parsePayload.d.ts +3 -0
- package/lib-esm/AwsClients/S3/utils/parsePayload.js +91 -0
- package/lib-esm/AwsClients/S3/utils/serializeHelpers.d.ts +42 -0
- package/lib-esm/AwsClients/S3/utils/serializeHelpers.js +176 -0
- package/lib-esm/Storage.d.ts +5 -5
- package/lib-esm/Storage.js +53 -25
- package/lib-esm/common/S3ClientUtils.d.ts +24 -15
- package/lib-esm/common/S3ClientUtils.js +76 -93
- package/lib-esm/common/StorageConstants.d.ts +0 -1
- package/lib-esm/common/StorageConstants.js +2 -2
- package/lib-esm/common/StorageErrorStrings.js +2 -1
- package/lib-esm/common/StorageUtils.js +2 -1
- package/lib-esm/index.js +1 -1
- package/lib-esm/providers/AWSS3Provider.d.ts +4 -8
- package/lib-esm/providers/AWSS3Provider.js +162 -115
- package/lib-esm/providers/AWSS3ProviderManagedUpload.d.ts +7 -7
- package/lib-esm/providers/AWSS3ProviderManagedUpload.js +172 -87
- package/lib-esm/providers/AWSS3UploadTask.d.ts +8 -8
- package/lib-esm/providers/AWSS3UploadTask.js +202 -106
- package/lib-esm/providers/index.js +2 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types/AWSS3Provider.d.ts +62 -62
- package/lib-esm/types/AWSS3Provider.js +1 -1
- package/lib-esm/types/Provider.d.ts +1 -1
- package/lib-esm/types/Provider.js +3 -1
- package/lib-esm/types/Storage.d.ts +23 -23
- package/lib-esm/types/Storage.js +1 -1
- package/lib-esm/types/index.js +3 -1
- package/package.json +21 -26
- package/src/AwsClients/S3/abortMultipartUpload.ts +62 -0
- package/src/AwsClients/S3/base.ts +109 -0
- package/src/AwsClients/S3/completeMultipartUpload.ts +154 -0
- package/src/AwsClients/S3/copyObject.ts +90 -0
- package/src/AwsClients/S3/createMultipartUpload.ts +75 -0
- package/src/AwsClients/S3/deleteObject.ts +69 -0
- package/src/AwsClients/S3/getObject.ts +173 -0
- package/src/AwsClients/S3/headObject.ts +91 -0
- package/src/AwsClients/S3/index.native.ts +42 -0
- package/src/AwsClients/S3/index.ts +41 -0
- package/src/AwsClients/S3/listObjectsV2.ts +130 -0
- package/src/AwsClients/S3/listParts.ts +97 -0
- package/src/AwsClients/S3/putObject.ts +94 -0
- package/src/AwsClients/S3/runtime/base64/index.browser.ts +21 -0
- package/src/AwsClients/S3/runtime/base64/index.native.ts +16 -0
- package/src/AwsClients/S3/runtime/constants.ts +16 -0
- package/src/AwsClients/S3/runtime/contentSha256middleware.ts +29 -0
- package/src/AwsClients/S3/runtime/index.browser.ts +14 -0
- package/src/AwsClients/S3/runtime/index.native.ts +14 -0
- package/src/AwsClients/S3/runtime/index.ts +15 -0
- package/src/AwsClients/S3/runtime/s3TransferHandler/fetch.ts +23 -0
- package/src/AwsClients/S3/runtime/s3TransferHandler/xhr.ts +35 -0
- package/src/AwsClients/S3/runtime/xhrTransferHandler.ts +254 -0
- package/src/AwsClients/S3/runtime/xmlParser/dom.ts +92 -0
- package/src/AwsClients/S3/runtime/xmlParser/pureJs.ts +55 -0
- package/src/AwsClients/S3/types.ts +2877 -0
- package/src/AwsClients/S3/uploadPart.ts +83 -0
- package/src/AwsClients/S3/utils/deserializeHelpers.ts +136 -0
- package/src/AwsClients/S3/utils/index.ts +27 -0
- package/src/AwsClients/S3/utils/parsePayload.ts +45 -0
- package/src/AwsClients/S3/utils/serializeHelpers.ts +112 -0
- package/src/Storage.ts +30 -27
- package/src/common/S3ClientUtils.ts +57 -113
- package/src/common/StorageConstants.ts +2 -2
- package/src/common/StorageErrorStrings.ts +2 -0
- package/src/common/StorageUtils.ts +2 -0
- package/src/providers/AWSS3Provider.ts +80 -100
- package/src/providers/AWSS3ProviderManagedUpload.ts +56 -63
- package/src/providers/AWSS3UploadTask.ts +86 -87
- package/src/providers/index.ts +2 -0
- package/src/types/AWSS3Provider.ts +55 -49
- package/src/types/Provider.ts +7 -2
- package/lib/.tsbuildinfo +0 -3
- package/lib/Storage.js.map +0 -1
- package/lib/common/S3ClientUtils.js.map +0 -1
- package/lib/common/StorageConstants.js.map +0 -1
- package/lib/common/StorageErrorStrings.js.map +0 -1
- package/lib/common/StorageUtils.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/providers/AWSS3Provider.js.map +0 -1
- package/lib/providers/AWSS3ProviderManagedUpload.js.map +0 -1
- package/lib/providers/AWSS3UploadTask.js.map +0 -1
- package/lib/providers/axios-http-handler.d.ts +0 -40
- package/lib/providers/axios-http-handler.js +0 -193
- package/lib/providers/axios-http-handler.js.map +0 -1
- package/lib/providers/index.js.map +0 -1
- package/lib/types/AWSS3Provider.js.map +0 -1
- package/lib/types/Provider.js.map +0 -1
- package/lib/types/Storage.js.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/Storage.js.map +0 -1
- package/lib-esm/common/S3ClientUtils.js.map +0 -1
- package/lib-esm/common/StorageConstants.js.map +0 -1
- package/lib-esm/common/StorageErrorStrings.js.map +0 -1
- package/lib-esm/common/StorageUtils.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/providers/AWSS3Provider.js.map +0 -1
- package/lib-esm/providers/AWSS3ProviderManagedUpload.js.map +0 -1
- package/lib-esm/providers/AWSS3UploadTask.js.map +0 -1
- package/lib-esm/providers/axios-http-handler.d.ts +0 -40
- package/lib-esm/providers/axios-http-handler.js +0 -191
- package/lib-esm/providers/axios-http-handler.js.map +0 -1
- package/lib-esm/providers/index.js.map +0 -1
- package/lib-esm/types/AWSS3Provider.js.map +0 -1
- package/lib-esm/types/Provider.js.map +0 -1
- package/lib-esm/types/Storage.js.map +0 -1
- package/lib-esm/types/index.js.map +0 -1
- package/src/providers/axios-http-handler.ts +0 -242
|
@@ -1,14 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
2
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
50
|
+
exports.calculatePartSize = exports.DEFAULT_QUEUE_SIZE = exports.MAX_PARTS_COUNT = exports.MAX_OBJECT_SIZE = exports.DEFAULT_PART_SIZE = exports.loadS3Config = exports.credentialsProvider = exports.getPrefix = void 0;
|
|
51
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
52
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
53
|
var core_1 = require("@aws-amplify/core");
|
|
5
|
-
var client_s3_1 = require("@aws-sdk/client-s3");
|
|
6
|
-
var axios_http_handler_1 = require("../providers/axios-http-handler");
|
|
7
54
|
var StorageConstants_1 = require("./StorageConstants");
|
|
8
55
|
var logger = new core_1.Logger('S3ClientUtils');
|
|
9
56
|
// placeholder credentials in order to satisfy type requirement, always results in 403 when used
|
|
10
57
|
var INVALID_CRED = { accessKeyId: '', secretAccessKey: '' };
|
|
11
|
-
|
|
58
|
+
var getPrefix = function (config) {
|
|
12
59
|
var credentials = config.credentials, level = config.level, customPrefix = config.customPrefix, identityId = config.identityId;
|
|
13
60
|
var resolvedCustomPrefix = customPrefix || {};
|
|
14
61
|
var resolvedIdentityId = identityId || credentials.identityId;
|
|
@@ -34,73 +81,10 @@ exports.getPrefix = function (config) {
|
|
|
34
81
|
return publicPath;
|
|
35
82
|
}
|
|
36
83
|
};
|
|
37
|
-
exports.
|
|
38
|
-
|
|
39
|
-
return function (args) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
40
|
-
var credentials, cred, prefix, clonedInput, result;
|
|
41
|
-
return tslib_1.__generator(this, function (_a) {
|
|
42
|
-
switch (_a.label) {
|
|
43
|
-
case 0: return [4 /*yield*/, core_1.Credentials.get()];
|
|
44
|
-
case 1:
|
|
45
|
-
credentials = _a.sent();
|
|
46
|
-
cred = core_1.Credentials.shear(credentials);
|
|
47
|
-
prefix = exports.getPrefix(tslib_1.__assign(tslib_1.__assign({}, opt), { credentials: cred }));
|
|
48
|
-
clonedInput = Object.assign({}, args.input);
|
|
49
|
-
if (Object.prototype.hasOwnProperty.call(args.input, 'Key')) {
|
|
50
|
-
clonedInput.Key = prefix + key;
|
|
51
|
-
args.input = clonedInput;
|
|
52
|
-
}
|
|
53
|
-
else if (Object.prototype.hasOwnProperty.call(args.input, 'Prefix')) {
|
|
54
|
-
clonedInput.Prefix = prefix + key;
|
|
55
|
-
args.input = clonedInput;
|
|
56
|
-
}
|
|
57
|
-
result = next(args);
|
|
58
|
-
return [2 /*return*/, result];
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}); };
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
var isTimeSkewedError = function (err) {
|
|
65
|
-
return err.ServerTime &&
|
|
66
|
-
typeof err.Code === 'string' &&
|
|
67
|
-
err.Code === 'RequestTimeTooSkewed';
|
|
68
|
-
};
|
|
69
|
-
// we want to take the S3Client config in parameter so we can modify it's systemClockOffset
|
|
70
|
-
exports.autoAdjustClockskewMiddleware = function (config) {
|
|
71
|
-
return function (next, _context) {
|
|
72
|
-
return function (args) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var err_1, serverDate;
|
|
74
|
-
return tslib_1.__generator(this, function (_a) {
|
|
75
|
-
switch (_a.label) {
|
|
76
|
-
case 0:
|
|
77
|
-
_a.trys.push([0, 2, , 3]);
|
|
78
|
-
return [4 /*yield*/, next(args)];
|
|
79
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
80
|
-
case 2:
|
|
81
|
-
err_1 = _a.sent();
|
|
82
|
-
if (isTimeSkewedError(err_1)) {
|
|
83
|
-
serverDate = new Date(err_1.ServerTime);
|
|
84
|
-
config.systemClockOffset = serverDate.getTime() - Date.now();
|
|
85
|
-
}
|
|
86
|
-
throw err_1;
|
|
87
|
-
case 3: return [2 /*return*/];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}); };
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
exports.autoAdjustClockskewMiddlewareOptions = {
|
|
94
|
-
step: 'finalizeRequest',
|
|
95
|
-
name: 'autoAdjustClockskewMiddleware',
|
|
96
|
-
};
|
|
97
|
-
exports.prefixMiddlewareOptions = {
|
|
98
|
-
step: 'initialize',
|
|
99
|
-
name: 'addPrefixMiddleware',
|
|
100
|
-
};
|
|
101
|
-
exports.credentialsProvider = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
84
|
+
exports.getPrefix = getPrefix;
|
|
85
|
+
var credentialsProvider = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
86
|
var credentials, cred, error_1;
|
|
103
|
-
return
|
|
87
|
+
return __generator(this, function (_a) {
|
|
104
88
|
switch (_a.label) {
|
|
105
89
|
case 0:
|
|
106
90
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -120,35 +104,39 @@ exports.credentialsProvider = function () { return tslib_1.__awaiter(void 0, voi
|
|
|
120
104
|
}
|
|
121
105
|
});
|
|
122
106
|
}); };
|
|
123
|
-
exports.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
107
|
+
exports.credentialsProvider = credentialsProvider;
|
|
108
|
+
/**
|
|
109
|
+
* A function that persists the s3 configs, so we don't need to
|
|
110
|
+
* assign each config parameter for every s3 API call.
|
|
111
|
+
*
|
|
112
|
+
* @inernal
|
|
113
|
+
*/
|
|
114
|
+
var loadS3Config = function (config) {
|
|
115
|
+
if (!config.region) {
|
|
116
|
+
// Same error thrown by aws-sdk
|
|
117
|
+
throw new Error('Region is missing.');
|
|
133
118
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
credentials: exports.credentialsProvider, customUserAgent: core_1.getAmplifyUserAgentObject({
|
|
119
|
+
return __assign(__assign(__assign({}, config), { region: config.region, credentials: config.credentials
|
|
120
|
+
? function () { return Promise.resolve(config.credentials); }
|
|
121
|
+
: exports.credentialsProvider, userAgentValue: (0, core_1.getAmplifyUserAgent)({
|
|
138
122
|
category: core_1.Category.Storage,
|
|
139
|
-
action: storageAction,
|
|
140
|
-
}) }
|
|
141
|
-
|
|
142
|
-
|
|
123
|
+
action: config.storageAction,
|
|
124
|
+
}) }), (config.dangerouslyConnectToHttpEndpointForTesting
|
|
125
|
+
? {
|
|
126
|
+
customEndpoint: StorageConstants_1.localTestingStorageEndpoint,
|
|
127
|
+
forcePathStyle: true,
|
|
128
|
+
}
|
|
129
|
+
: {}));
|
|
143
130
|
};
|
|
144
|
-
|
|
145
|
-
var
|
|
146
|
-
var
|
|
147
|
-
|
|
148
|
-
exports.
|
|
131
|
+
exports.loadS3Config = loadS3Config;
|
|
132
|
+
var MiB = 1024 * 1024;
|
|
133
|
+
var GiB = 1024 * MiB;
|
|
134
|
+
var TiB = 1024 * GiB;
|
|
135
|
+
exports.DEFAULT_PART_SIZE = 5 * MiB;
|
|
136
|
+
exports.MAX_OBJECT_SIZE = 5 * TiB;
|
|
149
137
|
exports.MAX_PARTS_COUNT = 10000;
|
|
150
138
|
exports.DEFAULT_QUEUE_SIZE = 4;
|
|
151
|
-
|
|
139
|
+
var calculatePartSize = function (totalSize) {
|
|
152
140
|
var partSize = exports.DEFAULT_PART_SIZE;
|
|
153
141
|
var partsCount = Math.ceil(totalSize / partSize);
|
|
154
142
|
while (partsCount > exports.MAX_PARTS_COUNT) {
|
|
@@ -157,4 +145,4 @@ exports.calculatePartSize = function (totalSize) {
|
|
|
157
145
|
}
|
|
158
146
|
return partSize;
|
|
159
147
|
};
|
|
160
|
-
|
|
148
|
+
exports.calculatePartSize = calculatePartSize;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UPLOADS_STORAGE_KEY = exports.localTestingStorageEndpoint = exports.AMPLIFY_SYMBOL = void 0;
|
|
4
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
6
|
exports.AMPLIFY_SYMBOL = (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function'
|
|
4
7
|
? Symbol.for('amplify_default')
|
|
5
8
|
: '@@amplify_default');
|
|
6
|
-
exports.SET_CONTENT_LENGTH_HEADER = 'contentLengthMiddleware';
|
|
7
9
|
exports.localTestingStorageEndpoint = 'http://localhost:20005';
|
|
8
10
|
exports.UPLOADS_STORAGE_KEY = '__uploadInProgress';
|
|
9
|
-
//# sourceMappingURL=StorageConstants.js.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AWSS3ProviderUploadErrorStrings = exports.AWSS3ProviderMultipartCopierErrors = exports.StorageErrorStrings = void 0;
|
|
4
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
6
|
var StorageErrorStrings;
|
|
4
7
|
(function (StorageErrorStrings) {
|
|
5
8
|
StorageErrorStrings["NO_CREDENTIALS"] = "No credentials";
|
|
@@ -19,4 +22,3 @@ var AWSS3ProviderUploadErrorStrings;
|
|
|
19
22
|
(function (AWSS3ProviderUploadErrorStrings) {
|
|
20
23
|
AWSS3ProviderUploadErrorStrings["UPLOAD_PAUSED_MESSAGE"] = "paused";
|
|
21
24
|
})(AWSS3ProviderUploadErrorStrings = exports.AWSS3ProviderUploadErrorStrings || (exports.AWSS3ProviderUploadErrorStrings = {}));
|
|
22
|
-
//# sourceMappingURL=StorageErrorStrings.js.map
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isBlob = exports.isFile = exports.dispatchStorageEvent = exports.byteLength = void 0;
|
|
4
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
6
|
var core_1 = require("@aws-amplify/core");
|
|
4
7
|
var StorageConstants_1 = require("./StorageConstants");
|
|
5
|
-
|
|
8
|
+
var byteLength = function (x) {
|
|
6
9
|
if (typeof x === 'string') {
|
|
7
10
|
return x.length;
|
|
8
11
|
}
|
|
9
12
|
else if (isArrayBuffer(x)) {
|
|
10
13
|
return x.byteLength;
|
|
11
14
|
}
|
|
12
|
-
else if (exports.isBlob(x)) {
|
|
15
|
+
else if ((0, exports.isBlob)(x)) {
|
|
13
16
|
return x.size;
|
|
14
17
|
}
|
|
15
18
|
else {
|
|
16
19
|
throw new Error('Cannot determine byte length of ' + x);
|
|
17
20
|
}
|
|
18
21
|
};
|
|
19
|
-
exports.
|
|
22
|
+
exports.byteLength = byteLength;
|
|
23
|
+
var dispatchStorageEvent = function (track, event, attrs, metrics, message) {
|
|
20
24
|
if (track) {
|
|
21
25
|
var data = { attrs: attrs };
|
|
22
26
|
if (metrics) {
|
|
@@ -29,13 +33,15 @@ exports.dispatchStorageEvent = function (track, event, attrs, metrics, message)
|
|
|
29
33
|
}, 'Storage', StorageConstants_1.AMPLIFY_SYMBOL);
|
|
30
34
|
}
|
|
31
35
|
};
|
|
32
|
-
exports.
|
|
36
|
+
exports.dispatchStorageEvent = dispatchStorageEvent;
|
|
37
|
+
var isFile = function (x) {
|
|
33
38
|
return typeof x !== 'undefined' && x instanceof File;
|
|
34
39
|
};
|
|
35
|
-
exports.
|
|
40
|
+
exports.isFile = isFile;
|
|
41
|
+
var isBlob = function (x) {
|
|
36
42
|
return typeof x !== 'undefined' && x instanceof Blob;
|
|
37
43
|
};
|
|
44
|
+
exports.isBlob = isBlob;
|
|
38
45
|
var isArrayBuffer = function (x) {
|
|
39
46
|
return typeof x !== 'undefined' && x instanceof ArrayBuffer;
|
|
40
47
|
};
|
|
41
|
-
//# sourceMappingURL=StorageUtils.js.map
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
4
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.AWSS3Provider = exports.Storage = exports.StorageClass = void 0;
|
|
5
20
|
var Storage_1 = require("./Storage");
|
|
6
|
-
exports
|
|
7
|
-
exports
|
|
21
|
+
Object.defineProperty(exports, "StorageClass", { enumerable: true, get: function () { return Storage_1.Storage; } });
|
|
22
|
+
Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return Storage_1.StorageInstance; } });
|
|
8
23
|
var providers_1 = require("./providers");
|
|
9
|
-
exports
|
|
10
|
-
|
|
24
|
+
Object.defineProperty(exports, "AWSS3Provider", { enumerable: true, get: function () { return providers_1.AWSS3Provider; } });
|
|
25
|
+
__exportStar(require("./types"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StorageOptions, StorageProvider, S3ProviderGetConfig, S3ProviderGetOuput, S3ProviderPutConfig, S3ProviderRemoveConfig, S3ProviderListConfig, S3ProviderCopyConfig, S3ProviderCopyOutput, S3CopySource, S3CopyDestination, S3ProviderRemoveOutput, S3ProviderPutOutput, S3ProviderListOutput,
|
|
1
|
+
import { PutObjectInput } from '../AwsClients/S3';
|
|
2
|
+
import { StorageOptions, StorageProvider, S3ProviderGetConfig, S3ProviderGetOuput, S3ProviderPutConfig, S3ProviderRemoveConfig, S3ProviderListConfig, S3ProviderCopyConfig, S3ProviderCopyOutput, S3CopySource, S3CopyDestination, S3ProviderRemoveOutput, S3ProviderPutOutput, S3ProviderListOutput, S3ProviderGetPropertiesConfig, S3ProviderGetPropertiesOutput } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Provide storage methods to use AWS S3
|
|
5
5
|
*/
|
|
@@ -44,7 +44,7 @@ export declare class AWSS3Provider implements StorageProvider {
|
|
|
44
44
|
*
|
|
45
45
|
* @param {string} key - key of the object
|
|
46
46
|
* @param {S3ProviderGetConfig} [config] - Optional configuration for the underlying S3 command
|
|
47
|
-
* @return {Promise<string |
|
|
47
|
+
* @return {Promise<string | GetObjectOutput>} - A promise resolves to Amazon S3 presigned URL or the
|
|
48
48
|
* GetObjectCommandOutput if download is set to true on success
|
|
49
49
|
*/
|
|
50
50
|
get<T extends S3ProviderGetConfig & StorageOptions>(key: string, config?: T): Promise<S3ProviderGetOuput<T>>;
|
|
@@ -65,7 +65,7 @@ export declare class AWSS3Provider implements StorageProvider {
|
|
|
65
65
|
* @return an instance of AWSS3UploadTask or a promise that resolves to an object with the new object's key on
|
|
66
66
|
* success.
|
|
67
67
|
*/
|
|
68
|
-
put<T extends S3ProviderPutConfig>(key: string, object:
|
|
68
|
+
put<T extends S3ProviderPutConfig>(key: string, object: PutObjectInput['Body'], config?: T): S3ProviderPutOutput<T>;
|
|
69
69
|
/**
|
|
70
70
|
* Remove the object for specified key
|
|
71
71
|
* @param {string} key - key of the object
|
|
@@ -85,8 +85,4 @@ export declare class AWSS3Provider implements StorageProvider {
|
|
|
85
85
|
private _ensureCredentials;
|
|
86
86
|
private _isWithCredentials;
|
|
87
87
|
private _prefix;
|
|
88
|
-
/**
|
|
89
|
-
* Creates an S3 client with new V3 aws sdk
|
|
90
|
-
*/
|
|
91
|
-
private _createNewS3Client;
|
|
92
88
|
}
|