@aws-amplify/storage 6.0.20 → 6.0.21-gen2-storage.7da2b89.0
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/errors/types/validation.js +18 -2
- package/dist/cjs/errors/types/validation.js.map +1 -1
- package/dist/cjs/providers/s3/apis/copy.js +1 -13
- package/dist/cjs/providers/s3/apis/copy.js.map +1 -1
- package/dist/cjs/providers/s3/apis/downloadData.js +11 -36
- package/dist/cjs/providers/s3/apis/downloadData.js.map +1 -1
- package/dist/cjs/providers/s3/apis/getProperties.js +1 -12
- package/dist/cjs/providers/s3/apis/getProperties.js.map +1 -1
- package/dist/cjs/providers/s3/apis/getUrl.js +1 -19
- package/dist/cjs/providers/s3/apis/getUrl.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/copy.js +41 -7
- package/dist/cjs/providers/s3/apis/internal/copy.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/getProperties.js +10 -6
- package/dist/cjs/providers/s3/apis/internal/getProperties.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/getUrl.js +13 -6
- package/dist/cjs/providers/s3/apis/internal/getUrl.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/remove.js +20 -7
- package/dist/cjs/providers/s3/apis/internal/remove.js.map +1 -1
- package/dist/cjs/providers/s3/apis/remove.js +1 -10
- package/dist/cjs/providers/s3/apis/remove.js.map +1 -1
- package/dist/cjs/providers/s3/apis/server/copy.js +3 -5
- package/dist/cjs/providers/s3/apis/server/copy.js.map +1 -1
- package/dist/cjs/providers/s3/apis/server/getProperties.js +1 -3
- package/dist/cjs/providers/s3/apis/server/getProperties.js.map +1 -1
- package/dist/cjs/providers/s3/apis/server/getUrl.js +1 -3
- package/dist/cjs/providers/s3/apis/server/getUrl.js.map +1 -1
- package/dist/cjs/providers/s3/apis/server/remove.js +1 -3
- package/dist/cjs/providers/s3/apis/server/remove.js.map +1 -1
- package/dist/cjs/providers/s3/utils/constants.js +3 -1
- package/dist/cjs/providers/s3/utils/constants.js.map +1 -1
- package/dist/cjs/providers/s3/utils/index.js +5 -1
- package/dist/cjs/providers/s3/utils/index.js.map +1 -1
- package/dist/cjs/providers/s3/utils/isInputWithPath.js +11 -0
- package/dist/cjs/providers/s3/utils/isInputWithPath.js.map +1 -0
- package/dist/cjs/providers/s3/utils/resolveS3ConfigAndInput.js +2 -1
- package/dist/cjs/providers/s3/utils/resolveS3ConfigAndInput.js.map +1 -1
- package/dist/cjs/providers/s3/utils/validateStorageOperationInput.js +31 -0
- package/dist/cjs/providers/s3/utils/validateStorageOperationInput.js.map +1 -0
- package/dist/esm/errors/types/validation.d.ts +6 -2
- package/dist/esm/errors/types/validation.mjs +18 -2
- package/dist/esm/errors/types/validation.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/copy.d.ts +29 -12
- package/dist/esm/providers/s3/apis/copy.mjs +1 -13
- package/dist/esm/providers/s3/apis/copy.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/downloadData.d.ts +70 -32
- package/dist/esm/providers/s3/apis/downloadData.mjs +12 -36
- package/dist/esm/providers/s3/apis/downloadData.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/getProperties.d.ts +28 -11
- package/dist/esm/providers/s3/apis/getProperties.mjs +1 -12
- package/dist/esm/providers/s3/apis/getProperties.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/getUrl.d.ts +42 -18
- package/dist/esm/providers/s3/apis/getUrl.mjs +1 -19
- package/dist/esm/providers/s3/apis/getUrl.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/copy.d.ts +3 -1
- package/dist/esm/providers/s3/apis/internal/copy.mjs +41 -6
- package/dist/esm/providers/s3/apis/internal/copy.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/getProperties.mjs +11 -6
- package/dist/esm/providers/s3/apis/internal/getProperties.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/getUrl.mjs +15 -7
- package/dist/esm/providers/s3/apis/internal/getUrl.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/remove.mjs +21 -7
- package/dist/esm/providers/s3/apis/internal/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/remove.d.ts +26 -9
- package/dist/esm/providers/s3/apis/remove.mjs +1 -10
- package/dist/esm/providers/s3/apis/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/server/copy.d.ts +31 -2
- package/dist/esm/providers/s3/apis/server/copy.mjs +1 -3
- package/dist/esm/providers/s3/apis/server/copy.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/server/getProperties.d.ts +30 -2
- package/dist/esm/providers/s3/apis/server/getProperties.mjs +1 -3
- package/dist/esm/providers/s3/apis/server/getProperties.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/server/getUrl.d.ts +44 -2
- package/dist/esm/providers/s3/apis/server/getUrl.mjs +1 -3
- package/dist/esm/providers/s3/apis/server/getUrl.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/server/remove.d.ts +28 -2
- package/dist/esm/providers/s3/apis/server/remove.mjs +1 -3
- package/dist/esm/providers/s3/apis/server/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/uploadData/multipart/uploadHandlers.d.ts +1 -1
- package/dist/esm/providers/s3/apis/uploadData/putObjectJob.d.ts +1 -1
- package/dist/esm/providers/s3/types/index.d.ts +3 -3
- package/dist/esm/providers/s3/types/inputs.d.ts +29 -7
- package/dist/esm/providers/s3/types/options.d.ts +23 -5
- package/dist/esm/providers/s3/types/outputs.d.ts +33 -10
- package/dist/esm/providers/s3/utils/constants.d.ts +2 -0
- package/dist/esm/providers/s3/utils/constants.mjs +3 -1
- package/dist/esm/providers/s3/utils/constants.mjs.map +1 -1
- package/dist/esm/providers/s3/utils/index.d.ts +2 -0
- package/dist/esm/providers/s3/utils/index.mjs +2 -0
- package/dist/esm/providers/s3/utils/index.mjs.map +1 -1
- package/dist/esm/providers/s3/utils/isInputWithPath.d.ts +2 -0
- package/dist/esm/providers/s3/utils/isInputWithPath.mjs +8 -0
- package/dist/esm/providers/s3/utils/isInputWithPath.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.d.ts +2 -1
- package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.mjs +2 -1
- package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.mjs.map +1 -1
- package/dist/esm/providers/s3/utils/validateStorageOperationInput.d.ts +5 -0
- package/dist/esm/providers/s3/utils/validateStorageOperationInput.mjs +29 -0
- package/dist/esm/providers/s3/utils/validateStorageOperationInput.mjs.map +1 -0
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/inputs.d.ts +42 -8
- package/dist/esm/types/options.d.ts +1 -0
- package/dist/esm/types/outputs.d.ts +22 -6
- package/package.json +107 -107
- package/src/errors/types/validation.ts +19 -2
- package/src/providers/s3/apis/copy.ts +38 -15
- package/src/providers/s3/apis/downloadData.ts +105 -47
- package/src/providers/s3/apis/getProperties.ts +38 -15
- package/src/providers/s3/apis/getUrl.ts +48 -22
- package/src/providers/s3/apis/internal/copy.ts +90 -8
- package/src/providers/s3/apis/internal/getProperties.ts +19 -9
- package/src/providers/s3/apis/internal/getUrl.ts +29 -11
- package/src/providers/s3/apis/internal/remove.ts +28 -10
- package/src/providers/s3/apis/remove.ts +35 -12
- package/src/providers/s3/apis/server/copy.ts +49 -6
- package/src/providers/s3/apis/server/getProperties.ts +48 -6
- package/src/providers/s3/apis/server/getUrl.ts +56 -5
- package/src/providers/s3/apis/server/remove.ts +46 -5
- package/src/providers/s3/apis/uploadData/multipart/uploadHandlers.ts +1 -1
- package/src/providers/s3/apis/uploadData/putObjectJob.ts +1 -1
- package/src/providers/s3/types/index.ts +26 -5
- package/src/providers/s3/types/inputs.ts +64 -18
- package/src/providers/s3/types/options.ts +44 -21
- package/src/providers/s3/types/outputs.ts +47 -10
- package/src/providers/s3/utils/constants.ts +3 -0
- package/src/providers/s3/utils/index.ts +2 -0
- package/src/providers/s3/utils/isInputWithPath.ts +13 -0
- package/src/providers/s3/utils/resolveS3ConfigAndInput.ts +3 -2
- package/src/providers/s3/utils/validateStorageOperationInput.ts +39 -0
- package/src/types/index.ts +12 -5
- package/src/types/inputs.ts +61 -11
- package/src/types/options.ts +1 -0
- package/src/types/outputs.ts +25 -6
|
@@ -1,25 +1,59 @@
|
|
|
1
|
+
import { StrictUnion } from '@aws-amplify/core/internals/utils';
|
|
1
2
|
import { StorageListAllOptions, StorageListPaginateOptions, StorageOptions } from './options';
|
|
2
|
-
export
|
|
3
|
+
export type StorageOperationInputType = StrictUnion<StorageOperationInputKey | StorageOperationInputPath>;
|
|
4
|
+
/** @deprecated Use {@link StorageOperationInputPath} instead. */
|
|
5
|
+
export interface StorageOperationInputKey {
|
|
6
|
+
/** @deprecated Use `path` instead. */
|
|
3
7
|
key: string;
|
|
8
|
+
}
|
|
9
|
+
export interface StorageOperationInputPath {
|
|
10
|
+
path: string | (({ identityId }: {
|
|
11
|
+
identityId?: string;
|
|
12
|
+
}) => string);
|
|
13
|
+
}
|
|
14
|
+
export interface StorageOperationOptionsInput<Options> {
|
|
4
15
|
options?: Options;
|
|
5
16
|
}
|
|
6
|
-
|
|
7
|
-
export
|
|
17
|
+
/** @deprecated Use {@link StorageDownloadDataInputPath} instead. */
|
|
18
|
+
export type StorageDownloadDataInputKey<Options extends StorageOptions> = StorageOperationInputKey & StorageOperationOptionsInput<Options>;
|
|
19
|
+
export type StorageDownloadDataInputPath<Options> = StorageOperationInputPath & StorageOperationOptionsInput<Options>;
|
|
20
|
+
export interface StorageOperationInput<Options extends StorageOptions> {
|
|
8
21
|
key: string;
|
|
9
22
|
options?: Options;
|
|
10
23
|
}
|
|
24
|
+
/** @deprecated Use {@link StorageGetPropertiesInputPath} instead. */
|
|
25
|
+
export type StorageGetPropertiesInputKey<Options extends StorageOptions> = StorageOperationInputKey & StorageOperationInput<Options>;
|
|
26
|
+
export type StorageGetPropertiesInputPath<Options> = StorageOperationInputPath & StorageOperationOptionsInput<Options>;
|
|
27
|
+
export type StorageRemoveInputKey<Options> = StorageOperationInputKey & StorageOperationOptionsInput<Options>;
|
|
28
|
+
export type StorageRemoveInputPath<Options> = StorageOperationInputPath & StorageOperationOptionsInput<Options>;
|
|
11
29
|
export interface StorageListInput<Options extends StorageListAllOptions | StorageListPaginateOptions> {
|
|
12
30
|
prefix?: string;
|
|
13
31
|
options?: Options;
|
|
14
32
|
}
|
|
15
|
-
|
|
16
|
-
export type
|
|
33
|
+
/** @deprecated Use {@link StorageGetUrlInputPath} instead. */
|
|
34
|
+
export type StorageGetUrlInputKey<Options extends StorageOptions> = StorageOperationInputKey & StorageOperationInput<Options>;
|
|
35
|
+
export type StorageGetUrlInputPath<Options> = StorageOperationInputPath & StorageOperationOptionsInput<Options>;
|
|
17
36
|
export type StorageUploadDataInput<Options extends StorageOptions> = StorageOperationInput<Options> & {
|
|
18
37
|
data: StorageUploadDataPayload;
|
|
19
38
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
39
|
+
/** @deprecated Use {@link StorageCopyInputPath} instead. */
|
|
40
|
+
export interface StorageCopyInputKey<SourceOptions extends StorageOptions, DestinationOptions extends StorageOptions> {
|
|
41
|
+
source: SourceOptions & {
|
|
42
|
+
path?: never;
|
|
43
|
+
};
|
|
44
|
+
destination: DestinationOptions & {
|
|
45
|
+
path?: never;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface StorageCopyInputPath {
|
|
49
|
+
source: StorageOperationInputPath & {
|
|
50
|
+
/** @deprecated Use path instead. */
|
|
51
|
+
key?: never;
|
|
52
|
+
};
|
|
53
|
+
destination: StorageOperationInputPath & {
|
|
54
|
+
/** @deprecated Use path instead. */
|
|
55
|
+
key?: never;
|
|
56
|
+
};
|
|
23
57
|
}
|
|
24
58
|
/**
|
|
25
59
|
* The data payload type for upload operation.
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ResponseBodyMixin } from '@aws-amplify/core/internals/aws-client-utils';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
key: string;
|
|
2
|
+
/**
|
|
3
|
+
* Base type for a storage item.
|
|
4
|
+
*/
|
|
5
|
+
export interface StorageItemBase {
|
|
7
6
|
/**
|
|
8
7
|
* Creation date of the object.
|
|
9
8
|
*/
|
|
@@ -23,7 +22,24 @@ export interface StorageItem {
|
|
|
23
22
|
*/
|
|
24
23
|
metadata?: Record<string, string>;
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
/** @deprecated Use {@link StorageItemPath} instead. */
|
|
26
|
+
export type StorageItemKey = StorageItemBase & {
|
|
27
|
+
/**
|
|
28
|
+
* Key of the object.
|
|
29
|
+
*/
|
|
30
|
+
key: string;
|
|
31
|
+
};
|
|
32
|
+
export type StorageItemPath = StorageItemBase & {
|
|
33
|
+
/**
|
|
34
|
+
* Path of the object.
|
|
35
|
+
*/
|
|
36
|
+
path: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A storage item can be identified either by a key or a path.
|
|
40
|
+
*/
|
|
41
|
+
export type StorageItem = StorageItemKey | StorageItemPath;
|
|
42
|
+
export type StorageDownloadDataOutput<Item extends StorageItem> = Item & {
|
|
27
43
|
body: ResponseBodyMixin;
|
|
28
44
|
};
|
|
29
45
|
export interface StorageGetUrlOutput {
|
package/package.json
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
2
|
+
"name": "@aws-amplify/storage",
|
|
3
|
+
"version": "6.0.21-gen2-storage.7da2b89.0+7da2b89",
|
|
4
|
+
"description": "Storage category of aws-amplify",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.mjs",
|
|
7
|
+
"react-native": {
|
|
8
|
+
"./dist/cjs/index": "./src/index.ts",
|
|
9
|
+
"fast-xml-parser": "fast-xml-parser",
|
|
10
|
+
"buffer": "buffer"
|
|
11
|
+
},
|
|
12
|
+
"typings": "./dist/esm/index.d.ts",
|
|
13
|
+
"browser": {
|
|
14
|
+
"./dist/esm/providers/s3/utils/client/runtime/base64/index.native.mjs": "./dist/esm/providers/s3/utils/client/runtime/base64/index.browser.mjs",
|
|
15
|
+
"./dist/esm/providers/s3/utils/client/runtime/s3TransferHandler/fetch.mjs": "./dist/esm/providers/s3/utils/client/runtime/s3TransferHandler/xhr.mjs",
|
|
16
|
+
"./dist/esm/providers/s3/utils/client/runtime/xmlParser/pureJs.mjs": "./dist/esm/providers/s3/utils/client/runtime/xmlParser/dom.mjs",
|
|
17
|
+
"fast-xml-parser": false,
|
|
18
|
+
"buffer": false
|
|
19
|
+
},
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
|
|
26
|
+
"build-with-test": "npm test && npm run build",
|
|
27
|
+
"build:umd": "webpack && webpack --config ./webpack.config.dev.js",
|
|
28
|
+
"build:esm-cjs": "rollup -c rollup.config.mjs",
|
|
29
|
+
"build:watch": "npm run build:esm-cjs -- --watch",
|
|
30
|
+
"build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
|
|
31
|
+
"clean": "npm run clean:size && rimraf lib-esm lib dist",
|
|
32
|
+
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
33
|
+
"format": "echo \"Not implemented\"",
|
|
34
|
+
"lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
|
|
35
|
+
"lint:fix": "eslint '**/*.{ts,tsx}' --fix",
|
|
36
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 90.31"
|
|
37
|
+
},
|
|
38
|
+
"typesVersions": {
|
|
39
|
+
">=4.2": {
|
|
40
|
+
"s3": [
|
|
41
|
+
"./dist/esm/providers/s3/index.d.ts"
|
|
42
|
+
],
|
|
43
|
+
"server": [
|
|
44
|
+
"./dist/esm/server.d.ts"
|
|
45
|
+
],
|
|
46
|
+
"s3/server": [
|
|
47
|
+
"./dist/esm/providers/s3/server.d.ts"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/aws-amplify/amplify-js.git"
|
|
54
|
+
},
|
|
55
|
+
"author": "Amazon Web Services",
|
|
56
|
+
"license": "Apache-2.0",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/aws/aws-amplify/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://aws-amplify.github.io/",
|
|
61
|
+
"files": [
|
|
62
|
+
"dist/cjs",
|
|
63
|
+
"dist/esm",
|
|
64
|
+
"src",
|
|
65
|
+
"server",
|
|
66
|
+
"s3"
|
|
67
|
+
],
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"@aws-sdk/types": "3.398.0",
|
|
70
|
+
"@smithy/md5-js": "2.0.7",
|
|
71
|
+
"buffer": "4.9.2",
|
|
72
|
+
"fast-xml-parser": "^4.2.5",
|
|
73
|
+
"tslib": "^2.5.0"
|
|
74
|
+
},
|
|
75
|
+
"exports": {
|
|
76
|
+
".": {
|
|
77
|
+
"types": "./dist/esm/index.d.ts",
|
|
78
|
+
"import": "./dist/esm/index.mjs",
|
|
79
|
+
"require": "./dist/cjs/index.js",
|
|
80
|
+
"react-native": "./src/index.ts"
|
|
81
|
+
},
|
|
82
|
+
"./server": {
|
|
83
|
+
"types": "./dist/esm/server.d.ts",
|
|
84
|
+
"import": "./dist/esm/server.mjs",
|
|
85
|
+
"require": "./dist/cjs/server.js"
|
|
86
|
+
},
|
|
87
|
+
"./s3": {
|
|
88
|
+
"types": "./dist/esm/providers/s3/index.d.ts",
|
|
89
|
+
"import": "./dist/esm/providers/s3/index.mjs",
|
|
90
|
+
"require": "./dist/cjs/providers/s3/index.js",
|
|
91
|
+
"react-native": "./src/providers/s3/index.ts"
|
|
92
|
+
},
|
|
93
|
+
"./s3/server": {
|
|
94
|
+
"types": "./dist/esm/providers/s3/server.d.ts",
|
|
95
|
+
"import": "./dist/esm/providers/s3/server.mjs",
|
|
96
|
+
"require": "./dist/cjs/providers/s3/server.js"
|
|
97
|
+
},
|
|
98
|
+
"./package.json": "./package.json"
|
|
99
|
+
},
|
|
100
|
+
"peerDependencies": {
|
|
101
|
+
"@aws-amplify/core": "6.0.21-gen2-storage.7da2b89.0+7da2b89"
|
|
102
|
+
},
|
|
103
|
+
"devDependencies": {
|
|
104
|
+
"@aws-amplify/core": "6.0.21-gen2-storage.7da2b89.0+7da2b89",
|
|
105
|
+
"@aws-amplify/react-native": "1.0.21-gen2-storage.7da2b89.0+7da2b89",
|
|
106
|
+
"typescript": "5.0.2"
|
|
107
|
+
},
|
|
108
|
+
"gitHead": "7da2b89404ba47b1a3f774a4b799e591b8cbebfb"
|
|
109
109
|
}
|
|
@@ -9,11 +9,15 @@ export enum StorageValidationErrorCode {
|
|
|
9
9
|
NoKey = 'NoKey',
|
|
10
10
|
NoSourceKey = 'NoSourceKey',
|
|
11
11
|
NoDestinationKey = 'NoDestinationKey',
|
|
12
|
+
NoSourcePath = 'NoSourcePath',
|
|
13
|
+
NoDestinationPath = 'NoDestinationPath',
|
|
12
14
|
NoBucket = 'NoBucket',
|
|
13
15
|
NoRegion = 'NoRegion',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
InvalidStorageOperationInput = 'InvalidStorageOperationInput',
|
|
17
|
+
InvalidStoragePathInput = 'InvalidStoragePathInput',
|
|
16
18
|
InvalidUploadSource = 'InvalidUploadSource',
|
|
19
|
+
ObjectIsTooLarge = 'ObjectIsTooLarge',
|
|
20
|
+
UrlExpirationMaxLimitExceed = 'UrlExpirationMaxLimitExceed',
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
export const validationErrorMap: AmplifyErrorMap<StorageValidationErrorCode> = {
|
|
@@ -33,6 +37,12 @@ export const validationErrorMap: AmplifyErrorMap<StorageValidationErrorCode> = {
|
|
|
33
37
|
[StorageValidationErrorCode.NoDestinationKey]: {
|
|
34
38
|
message: 'Missing destination key in copy api call.',
|
|
35
39
|
},
|
|
40
|
+
[StorageValidationErrorCode.NoSourcePath]: {
|
|
41
|
+
message: 'Missing source path in copy api call.',
|
|
42
|
+
},
|
|
43
|
+
[StorageValidationErrorCode.NoDestinationPath]: {
|
|
44
|
+
message: 'Missing destination path in copy api call.',
|
|
45
|
+
},
|
|
36
46
|
[StorageValidationErrorCode.NoBucket]: {
|
|
37
47
|
message: 'Missing bucket name while accessing object.',
|
|
38
48
|
},
|
|
@@ -49,4 +59,11 @@ export const validationErrorMap: AmplifyErrorMap<StorageValidationErrorCode> = {
|
|
|
49
59
|
message:
|
|
50
60
|
'Upload source type can only be a `Blob`, `File`, `ArrayBuffer`, or `string`.',
|
|
51
61
|
},
|
|
62
|
+
[StorageValidationErrorCode.InvalidStorageOperationInput]: {
|
|
63
|
+
message:
|
|
64
|
+
'Path or key parameter must be specified in the input. Both can not be specified at the same time.',
|
|
65
|
+
},
|
|
66
|
+
[StorageValidationErrorCode.InvalidStoragePathInput]: {
|
|
67
|
+
message: 'Input `path` does not allow a leading slash (/).',
|
|
68
|
+
},
|
|
52
69
|
};
|
|
@@ -3,21 +3,44 @@
|
|
|
3
3
|
|
|
4
4
|
import { Amplify } from '@aws-amplify/core';
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
CopyInput,
|
|
8
|
+
CopyInputKey,
|
|
9
|
+
CopyInputPath,
|
|
10
|
+
CopyOutput,
|
|
11
|
+
CopyOutputKey,
|
|
12
|
+
CopyOutputPath,
|
|
13
|
+
} from '../types';
|
|
8
14
|
|
|
9
15
|
import { copy as copyInternal } from './internal/copy';
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
interface Copy {
|
|
18
|
+
/**
|
|
19
|
+
* Copy an object from a source to a destination object within the same bucket.
|
|
20
|
+
*
|
|
21
|
+
* @param input - The CopyInputPath object.
|
|
22
|
+
* @returns Output containing the destination object path.
|
|
23
|
+
* @throws service: `S3Exception` - Thrown when checking for existence of the object
|
|
24
|
+
* @throws validation: `StorageValidationErrorCode` - Thrown when
|
|
25
|
+
* source or destination path is not defined.
|
|
26
|
+
*/
|
|
27
|
+
(input: CopyInputPath): Promise<CopyOutputPath>;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
|
|
30
|
+
* Please use {@link https://docs.amplify.aws/react/build-a-backend/storage/copy | path} instead.
|
|
31
|
+
*
|
|
32
|
+
* Copy an object from a source to a destination object within the same bucket. Can optionally copy files across
|
|
33
|
+
* different accessLevel or identityId (if source object's accessLevel is 'protected').
|
|
34
|
+
*
|
|
35
|
+
* @param input - The CopyInputKey object.
|
|
36
|
+
* @returns Output containing the destination object key.
|
|
37
|
+
* @throws service: `S3Exception` - Thrown when checking for existence of the object
|
|
38
|
+
* @throws validation: `StorageValidationErrorCode` - Thrown when
|
|
39
|
+
* source or destination key is not defined.
|
|
40
|
+
*/
|
|
41
|
+
(input: CopyInputKey): Promise<CopyOutputKey>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const copy: Copy = <Output extends CopyOutput>(
|
|
45
|
+
input: CopyInput,
|
|
46
|
+
): Promise<Output> => copyInternal(Amplify, input) as Promise<Output>;
|
|
@@ -4,45 +4,97 @@
|
|
|
4
4
|
import { Amplify } from '@aws-amplify/core';
|
|
5
5
|
import { StorageAction } from '@aws-amplify/core/internals/utils';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
DownloadDataInput,
|
|
9
|
+
DownloadDataInputKey,
|
|
10
|
+
DownloadDataInputPath,
|
|
11
|
+
DownloadDataOutput,
|
|
12
|
+
DownloadDataOutputKey,
|
|
13
|
+
DownloadDataOutputPath,
|
|
14
|
+
} from '../types';
|
|
8
15
|
import { resolveS3ConfigAndInput } from '../utils/resolveS3ConfigAndInput';
|
|
9
|
-
import {
|
|
10
|
-
import { createDownloadTask } from '../utils';
|
|
16
|
+
import { createDownloadTask, validateStorageOperationInput } from '../utils';
|
|
11
17
|
import { getObject } from '../utils/client';
|
|
12
18
|
import { getStorageUserAgentValue } from '../utils/userAgent';
|
|
13
19
|
import { logger } from '../../../utils';
|
|
20
|
+
import {
|
|
21
|
+
StorageDownloadDataOutput,
|
|
22
|
+
StorageItemKey,
|
|
23
|
+
StorageItemPath,
|
|
24
|
+
} from '../../../types';
|
|
25
|
+
import { STORAGE_INPUT_KEY } from '../utils/constants';
|
|
14
26
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
27
|
+
interface DownloadData {
|
|
28
|
+
/**
|
|
29
|
+
* Download S3 object data to memory
|
|
30
|
+
*
|
|
31
|
+
* @param input - The DownloadDataInputPath object.
|
|
32
|
+
* @returns A cancelable task exposing result promise from `result` property.
|
|
33
|
+
* @throws service: `S3Exception` - thrown when checking for existence of the object
|
|
34
|
+
* @throws validation: `StorageValidationErrorCode` - Validation errors
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* // Download a file from s3 bucket
|
|
39
|
+
* const { body, eTag } = await downloadData({ path, options: {
|
|
40
|
+
* onProgress, // Optional progress callback.
|
|
41
|
+
* } }).result;
|
|
42
|
+
* ```
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* // Cancel a task
|
|
46
|
+
* const downloadTask = downloadData({ path });
|
|
47
|
+
* //...
|
|
48
|
+
* downloadTask.cancel();
|
|
49
|
+
* try {
|
|
50
|
+
* await downloadTask.result;
|
|
51
|
+
* } catch (error) {
|
|
52
|
+
* if(isCancelError(error)) {
|
|
53
|
+
* // Handle error thrown by task cancelation.
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
*```
|
|
57
|
+
*/
|
|
58
|
+
(input: DownloadDataInputPath): DownloadDataOutputPath;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
|
|
61
|
+
* Please use {@link https://docs.amplify.aws/react/build-a-backend/storage/download/#downloaddata | path} instead.
|
|
62
|
+
*
|
|
63
|
+
* Download S3 object data to memory
|
|
64
|
+
*
|
|
65
|
+
* @param input - The DownloadDataInputKey object.
|
|
66
|
+
* @returns A cancelable task exposing result promise from `result` property.
|
|
67
|
+
* @throws service: `S3Exception` - thrown when checking for existence of the object
|
|
68
|
+
* @throws validation: `StorageValidationErrorCode` - Validation errors
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* // Download a file from s3 bucket
|
|
73
|
+
* const { body, eTag } = await downloadData({ key, options: {
|
|
74
|
+
* onProgress, // Optional progress callback.
|
|
75
|
+
* } }).result;
|
|
76
|
+
* ```
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* // Cancel a task
|
|
80
|
+
* const downloadTask = downloadData({ key });
|
|
81
|
+
* //...
|
|
82
|
+
* downloadTask.cancel();
|
|
83
|
+
* try {
|
|
84
|
+
* await downloadTask.result;
|
|
85
|
+
* } catch (error) {
|
|
86
|
+
* if(isCancelError(error)) {
|
|
87
|
+
* // Handle error thrown by task cancelation.
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
*```
|
|
91
|
+
*/
|
|
92
|
+
(input: DownloadDataInputKey): DownloadDataOutputKey;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const downloadData: DownloadData = <Output extends DownloadDataOutput>(
|
|
96
|
+
input: DownloadDataInput,
|
|
97
|
+
): Output => {
|
|
46
98
|
const abortController = new AbortController();
|
|
47
99
|
|
|
48
100
|
const downloadTask = createDownloadTask({
|
|
@@ -52,22 +104,25 @@ export const downloadData = (input: DownloadDataInput): DownloadDataOutput => {
|
|
|
52
104
|
},
|
|
53
105
|
});
|
|
54
106
|
|
|
55
|
-
return downloadTask;
|
|
107
|
+
return downloadTask as Output;
|
|
56
108
|
};
|
|
57
109
|
|
|
58
110
|
const downloadDataJob =
|
|
59
|
-
(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const { bucket, keyPrefix, s3Config } =
|
|
65
|
-
Amplify,
|
|
66
|
-
|
|
111
|
+
(downloadDataInput: DownloadDataInput, abortSignal: AbortSignal) =>
|
|
112
|
+
async (): Promise<
|
|
113
|
+
StorageDownloadDataOutput<StorageItemKey | StorageItemPath>
|
|
114
|
+
> => {
|
|
115
|
+
const { options: downloadDataOptions } = downloadDataInput;
|
|
116
|
+
const { bucket, keyPrefix, s3Config, identityId } =
|
|
117
|
+
await resolveS3ConfigAndInput(Amplify, downloadDataOptions);
|
|
118
|
+
const { inputType, objectKey } = validateStorageOperationInput(
|
|
119
|
+
downloadDataInput,
|
|
120
|
+
identityId,
|
|
67
121
|
);
|
|
68
|
-
const finalKey =
|
|
122
|
+
const finalKey =
|
|
123
|
+
inputType === STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;
|
|
69
124
|
|
|
70
|
-
logger.debug(`download ${
|
|
125
|
+
logger.debug(`download ${objectKey} from ${finalKey}.`);
|
|
71
126
|
|
|
72
127
|
const {
|
|
73
128
|
Body: body,
|
|
@@ -93,8 +148,7 @@ const downloadDataJob =
|
|
|
93
148
|
},
|
|
94
149
|
);
|
|
95
150
|
|
|
96
|
-
|
|
97
|
-
key,
|
|
151
|
+
const result = {
|
|
98
152
|
body,
|
|
99
153
|
lastModified,
|
|
100
154
|
size,
|
|
@@ -103,4 +157,8 @@ const downloadDataJob =
|
|
|
103
157
|
metadata,
|
|
104
158
|
versionId,
|
|
105
159
|
};
|
|
160
|
+
|
|
161
|
+
return inputType === STORAGE_INPUT_KEY
|
|
162
|
+
? { key: objectKey, ...result }
|
|
163
|
+
: { path: finalKey, ...result };
|
|
106
164
|
};
|