@aws-amplify/storage 6.11.2-unstable.a361dd1.0 → 6.12.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/internals/apis/remove.js +13 -12
- package/dist/cjs/internals/apis/remove.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/remove.js +53 -29
- package/dist/cjs/providers/s3/apis/internal/remove.js.map +1 -1
- package/dist/cjs/providers/s3/apis/remove.js +6 -1
- package/dist/cjs/providers/s3/apis/remove.js.map +1 -1
- package/dist/cjs/providers/s3/apis/server/remove.js +6 -1
- package/dist/cjs/providers/s3/apis/server/remove.js.map +1 -1
- package/dist/cjs/providers/s3/utils/client/s3data/deleteObjects.js +70 -0
- package/dist/cjs/providers/s3/utils/client/s3data/deleteObjects.js.map +1 -0
- package/dist/cjs/providers/s3/utils/client/s3data/index.js +3 -1
- package/dist/cjs/providers/s3/utils/client/s3data/index.js.map +1 -1
- package/dist/cjs/providers/s3/utils/createAbortableTask.js +35 -0
- package/dist/cjs/providers/s3/utils/createAbortableTask.js.map +1 -0
- package/dist/cjs/providers/s3/utils/deleteFolderContents.js +80 -0
- package/dist/cjs/providers/s3/utils/deleteFolderContents.js.map +1 -0
- package/dist/cjs/providers/s3/utils/generateDeleteObjectsXml.js +38 -0
- package/dist/cjs/providers/s3/utils/generateDeleteObjectsXml.js.map +1 -0
- package/dist/cjs/providers/s3/utils/index.js +13 -1
- package/dist/cjs/providers/s3/utils/index.js.map +1 -1
- package/dist/cjs/providers/s3/utils/isPathFolder.js +38 -0
- package/dist/cjs/providers/s3/utils/isPathFolder.js.map +1 -0
- package/dist/cjs/providers/s3/utils/resolveFinalKey.js +22 -0
- package/dist/cjs/providers/s3/utils/resolveFinalKey.js.map +1 -0
- package/dist/cjs/providers/s3/utils/validateRemovePath.js +21 -0
- package/dist/cjs/providers/s3/utils/validateRemovePath.js.map +1 -0
- package/dist/esm/internals/apis/remove.d.ts +2 -1
- package/dist/esm/internals/apis/remove.mjs +13 -12
- package/dist/esm/internals/apis/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/copy.mjs +8 -7
- package/dist/esm/providers/s3/apis/internal/copy.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/downloadData.d.ts +1 -1
- package/dist/esm/providers/s3/apis/internal/downloadData.mjs +6 -5
- package/dist/esm/providers/s3/apis/internal/downloadData.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/getProperties.mjs +7 -6
- package/dist/esm/providers/s3/apis/internal/getProperties.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/getUrl.mjs +2 -1
- package/dist/esm/providers/s3/apis/internal/getUrl.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/list.mjs +8 -7
- package/dist/esm/providers/s3/apis/internal/list.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/remove.d.ts +3 -2
- package/dist/esm/providers/s3/apis/internal/remove.mjs +58 -27
- package/dist/esm/providers/s3/apis/internal/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/index.mjs +13 -0
- package/dist/esm/providers/s3/apis/internal/uploadData/index.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/initialUpload.mjs +1 -0
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/initialUpload.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadCache.mjs +1 -0
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadCache.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadHandlers.mjs +6 -5
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadHandlers.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadPartExecutor.mjs +1 -0
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadPartExecutor.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/putObjectJob.mjs +7 -6
- package/dist/esm/providers/s3/apis/internal/uploadData/putObjectJob.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/remove.d.ts +6 -6
- package/dist/esm/providers/s3/apis/remove.mjs +6 -1
- package/dist/esm/providers/s3/apis/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/server/remove.d.ts +6 -6
- package/dist/esm/providers/s3/apis/server/remove.mjs +6 -1
- package/dist/esm/providers/s3/apis/server/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/types/index.d.ts +1 -1
- package/dist/esm/providers/s3/types/inputs.d.ts +24 -1
- package/dist/esm/providers/s3/utils/client/s3data/deleteObjects.d.ts +30 -0
- package/dist/esm/providers/s3/utils/client/s3data/deleteObjects.mjs +74 -0
- package/dist/esm/providers/s3/utils/client/s3data/deleteObjects.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/client/s3data/index.d.ts +1 -0
- package/dist/esm/providers/s3/utils/client/s3data/index.mjs +1 -0
- package/dist/esm/providers/s3/utils/client/s3data/index.mjs.map +1 -1
- package/dist/esm/providers/s3/utils/client/s3data/types.d.ts +26 -0
- package/dist/esm/providers/s3/utils/createAbortableTask.d.ts +6 -0
- package/dist/esm/providers/s3/utils/createAbortableTask.mjs +33 -0
- package/dist/esm/providers/s3/utils/createAbortableTask.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/deleteFolderContents.d.ts +16 -0
- package/dist/esm/providers/s3/utils/deleteFolderContents.mjs +90 -0
- package/dist/esm/providers/s3/utils/deleteFolderContents.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/generateDeleteObjectsXml.d.ts +10 -0
- package/dist/esm/providers/s3/utils/generateDeleteObjectsXml.mjs +35 -0
- package/dist/esm/providers/s3/utils/generateDeleteObjectsXml.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/index.d.ts +6 -0
- package/dist/esm/providers/s3/utils/index.mjs +6 -0
- package/dist/esm/providers/s3/utils/index.mjs.map +1 -1
- package/dist/esm/providers/s3/utils/isPathFolder.d.ts +13 -0
- package/dist/esm/providers/s3/utils/isPathFolder.mjs +48 -0
- package/dist/esm/providers/s3/utils/isPathFolder.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/resolveFinalKey.d.ts +9 -0
- package/dist/esm/providers/s3/utils/resolveFinalKey.mjs +20 -0
- package/dist/esm/providers/s3/utils/resolveFinalKey.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/validateRemovePath.d.ts +8 -0
- package/dist/esm/providers/s3/utils/validateRemovePath.mjs +18 -0
- package/dist/esm/providers/s3/utils/validateRemovePath.mjs.map +1 -0
- package/dist/esm/types/common.d.ts +3 -0
- package/package.json +117 -117
- package/src/internals/apis/remove.ts +17 -10
- package/src/providers/s3/apis/internal/remove.ts +96 -41
- package/src/providers/s3/apis/remove.ts +11 -6
- package/src/providers/s3/apis/server/remove.ts +11 -6
- package/src/providers/s3/types/index.ts +2 -0
- package/src/providers/s3/types/inputs.ts +24 -1
- package/src/providers/s3/utils/client/s3data/deleteObjects.ts +122 -0
- package/src/providers/s3/utils/client/s3data/index.ts +5 -0
- package/src/providers/s3/utils/client/s3data/types.ts +20 -0
- package/src/providers/s3/utils/createAbortableTask.ts +45 -0
- package/src/providers/s3/utils/deleteFolderContents.ts +118 -0
- package/src/providers/s3/utils/generateDeleteObjectsXml.ts +38 -0
- package/src/providers/s3/utils/index.ts +6 -0
- package/src/providers/s3/utils/isPathFolder.ts +50 -0
- package/src/providers/s3/utils/resolveFinalKey.ts +22 -0
- package/src/providers/s3/utils/validateRemovePath.ts +16 -0
- package/src/types/common.ts +5 -0
|
@@ -32,5 +32,8 @@ export interface TransferTask<Result> {
|
|
|
32
32
|
*/
|
|
33
33
|
result: Promise<Result>;
|
|
34
34
|
}
|
|
35
|
+
export interface NonPausableTransferTask<T> extends Omit<TransferTask<T>, 'pause' | 'resume' | 'state'> {
|
|
36
|
+
state: Omit<TransferTask<T>['state'], 'PAUSED'>;
|
|
37
|
+
}
|
|
35
38
|
export type DownloadTask<Result> = Omit<TransferTask<Result>, 'pause' | 'resume'>;
|
|
36
39
|
export type UploadTask<Result> = TransferTask<Result>;
|
package/package.json
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
2
|
+
"name": "@aws-amplify/storage",
|
|
3
|
+
"version": "6.12.0",
|
|
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 --forceExit -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
|
+
"internals": [
|
|
44
|
+
"./dist/esm/internals/index.d.ts"
|
|
45
|
+
],
|
|
46
|
+
"server": [
|
|
47
|
+
"./dist/esm/server.d.ts"
|
|
48
|
+
],
|
|
49
|
+
"s3/server": [
|
|
50
|
+
"./dist/esm/providers/s3/server.d.ts"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "https://github.com/aws-amplify/amplify-js.git"
|
|
57
|
+
},
|
|
58
|
+
"author": "Amazon Web Services",
|
|
59
|
+
"license": "Apache-2.0",
|
|
60
|
+
"bugs": {
|
|
61
|
+
"url": "https://github.com/aws/aws-amplify/issues"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://aws-amplify.github.io/",
|
|
64
|
+
"files": [
|
|
65
|
+
"dist/cjs",
|
|
66
|
+
"dist/esm",
|
|
67
|
+
"internals",
|
|
68
|
+
"src",
|
|
69
|
+
"server",
|
|
70
|
+
"s3"
|
|
71
|
+
],
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@aws-sdk/types": "3.723.0",
|
|
74
|
+
"@smithy/md5-js": "2.0.7",
|
|
75
|
+
"buffer": "4.9.2",
|
|
76
|
+
"crc-32": "1.2.2",
|
|
77
|
+
"fast-xml-parser": "^4.4.1",
|
|
78
|
+
"tslib": "^2.5.0"
|
|
79
|
+
},
|
|
80
|
+
"exports": {
|
|
81
|
+
".": {
|
|
82
|
+
"react-native": "./dist/cjs/index.js",
|
|
83
|
+
"types": "./dist/esm/index.d.ts",
|
|
84
|
+
"import": "./dist/esm/index.mjs",
|
|
85
|
+
"require": "./dist/cjs/index.js"
|
|
86
|
+
},
|
|
87
|
+
"./internals": {
|
|
88
|
+
"types": "./dist/esm/internals/index.d.ts",
|
|
89
|
+
"import": "./dist/esm/internals/index.mjs",
|
|
90
|
+
"require": "./dist/cjs/internals/index.js"
|
|
91
|
+
},
|
|
92
|
+
"./server": {
|
|
93
|
+
"types": "./dist/esm/server.d.ts",
|
|
94
|
+
"import": "./dist/esm/server.mjs",
|
|
95
|
+
"require": "./dist/cjs/server.js"
|
|
96
|
+
},
|
|
97
|
+
"./s3": {
|
|
98
|
+
"react-native": "./dist/cjs/providers/s3/index.js",
|
|
99
|
+
"types": "./dist/esm/providers/s3/index.d.ts",
|
|
100
|
+
"import": "./dist/esm/providers/s3/index.mjs",
|
|
101
|
+
"require": "./dist/cjs/providers/s3/index.js"
|
|
102
|
+
},
|
|
103
|
+
"./s3/server": {
|
|
104
|
+
"types": "./dist/esm/providers/s3/server.d.ts",
|
|
105
|
+
"import": "./dist/esm/providers/s3/server.mjs",
|
|
106
|
+
"require": "./dist/cjs/providers/s3/server.js"
|
|
107
|
+
},
|
|
108
|
+
"./package.json": "./package.json"
|
|
109
|
+
},
|
|
110
|
+
"peerDependencies": {
|
|
111
|
+
"@aws-amplify/core": "^6.1.0"
|
|
112
|
+
},
|
|
113
|
+
"devDependencies": {
|
|
114
|
+
"@aws-amplify/core": "6.16.0",
|
|
115
|
+
"@aws-amplify/react-native": "1.3.2",
|
|
116
|
+
"@types/node": "20.14.12"
|
|
117
|
+
},
|
|
118
|
+
"gitHead": "07bd4bd1d05d07fa516fb596fb1712ef812ed20c"
|
|
119
119
|
}
|
|
@@ -4,22 +4,29 @@
|
|
|
4
4
|
import { Amplify } from '@aws-amplify/core';
|
|
5
5
|
|
|
6
6
|
import { remove as removeInternal } from '../../providers/s3/apis/internal/remove';
|
|
7
|
+
import { RemoveOperation } from '../../providers/s3/types';
|
|
7
8
|
import { RemoveInput } from '../types/inputs';
|
|
8
9
|
import { RemoveOutput } from '../types/outputs';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @internal
|
|
12
13
|
*/
|
|
13
|
-
export const remove = (input: RemoveInput):
|
|
14
|
-
removeInternal(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
export const remove = (input: RemoveInput): RemoveOperation<RemoveOutput> => {
|
|
15
|
+
return removeInternal(
|
|
16
|
+
Amplify,
|
|
17
|
+
{
|
|
18
|
+
path: input.path,
|
|
19
|
+
options: {
|
|
20
|
+
useAccelerateEndpoint: input?.options?.useAccelerateEndpoint,
|
|
21
|
+
bucket: input?.options?.bucket,
|
|
22
|
+
expectedBucketOwner: input?.options?.expectedBucketOwner,
|
|
23
|
+
locationCredentialsProvider:
|
|
24
|
+
input?.options?.locationCredentialsProvider,
|
|
25
|
+
customEndpoint: input?.options?.customEndpoint,
|
|
26
|
+
onProgress: input?.options?.onProgress,
|
|
27
|
+
},
|
|
22
28
|
},
|
|
23
29
|
// Type casting is necessary because `removeInternal` supports both Gen1 and Gen2 signatures, but here
|
|
24
30
|
// given in input can only be Gen2 signature, the return can only ben Gen2 signature.
|
|
25
|
-
|
|
31
|
+
) as RemoveOperation<RemoveOutput>;
|
|
32
|
+
};
|
|
@@ -4,58 +4,113 @@
|
|
|
4
4
|
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
5
5
|
import { StorageAction } from '@aws-amplify/core/internals/utils';
|
|
6
6
|
|
|
7
|
-
import { RemoveInput, RemoveOutput, RemoveWithPathOutput } from '../../types';
|
|
8
7
|
import {
|
|
8
|
+
RemoveInput,
|
|
9
|
+
RemoveOperation,
|
|
10
|
+
RemoveOutput,
|
|
11
|
+
RemoveWithPathOutput,
|
|
12
|
+
} from '../../types';
|
|
13
|
+
import {
|
|
14
|
+
deleteFolderContents,
|
|
15
|
+
isPathFolder,
|
|
16
|
+
resolveFinalKey,
|
|
9
17
|
resolveS3ConfigAndInput,
|
|
10
18
|
validateBucketOwnerID,
|
|
19
|
+
validateRemovePath,
|
|
11
20
|
validateStorageOperationInput,
|
|
12
21
|
} from '../../utils';
|
|
13
22
|
import { deleteObject } from '../../utils/client/s3data';
|
|
14
23
|
import { getStorageUserAgentValue } from '../../utils/userAgent';
|
|
15
|
-
import { logger } from '../../../../utils';
|
|
16
24
|
import { STORAGE_INPUT_KEY } from '../../utils/constants';
|
|
25
|
+
import { createAbortableTask } from '../../utils/createAbortableTask';
|
|
17
26
|
// TODO: Remove this interface when we move to public advanced APIs.
|
|
18
27
|
import { RemoveInput as RemoveWithPathInputWithAdvancedOptions } from '../../../../internals';
|
|
28
|
+
import { CanceledError } from '../../../../errors/CanceledError';
|
|
19
29
|
|
|
20
|
-
export
|
|
30
|
+
export function remove(
|
|
31
|
+
amplify: AmplifyClassV6,
|
|
32
|
+
input: RemoveInput,
|
|
33
|
+
): RemoveOperation<RemoveOutput>;
|
|
34
|
+
export function remove(
|
|
35
|
+
amplify: AmplifyClassV6,
|
|
36
|
+
input: RemoveWithPathInputWithAdvancedOptions,
|
|
37
|
+
): RemoveOperation<RemoveWithPathOutput>;
|
|
38
|
+
export function remove(
|
|
21
39
|
amplify: AmplifyClassV6,
|
|
22
40
|
input: RemoveInput | RemoveWithPathInputWithAdvancedOptions,
|
|
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
|
-
|
|
41
|
+
): RemoveOperation<RemoveOutput | RemoveWithPathOutput> {
|
|
42
|
+
return createAbortableTask(executeRemove(amplify, input));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const executeRemove =
|
|
46
|
+
(
|
|
47
|
+
amplify: AmplifyClassV6,
|
|
48
|
+
input: RemoveInput | RemoveWithPathInputWithAdvancedOptions,
|
|
49
|
+
) =>
|
|
50
|
+
async (abortController: AbortController) => {
|
|
51
|
+
try {
|
|
52
|
+
const { s3Config, keyPrefix, bucket, identityId } =
|
|
53
|
+
await resolveS3ConfigAndInput(amplify, input);
|
|
54
|
+
|
|
55
|
+
const { inputType, objectKey } = validateStorageOperationInput(
|
|
56
|
+
input,
|
|
57
|
+
identityId,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
validateBucketOwnerID(input.options?.expectedBucketOwner);
|
|
61
|
+
|
|
62
|
+
const finalKey = resolveFinalKey(inputType, objectKey, keyPrefix);
|
|
63
|
+
|
|
64
|
+
validateRemovePath(finalKey);
|
|
65
|
+
|
|
66
|
+
const isFolder =
|
|
67
|
+
finalKey.endsWith('/') ||
|
|
68
|
+
(await isPathFolder({
|
|
69
|
+
s3Config,
|
|
70
|
+
bucket,
|
|
71
|
+
key: finalKey,
|
|
72
|
+
expectedBucketOwner: input.options?.expectedBucketOwner,
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
if (isFolder) {
|
|
76
|
+
return deleteFolderContents({
|
|
77
|
+
s3Config,
|
|
78
|
+
bucket,
|
|
79
|
+
folderKey: finalKey,
|
|
80
|
+
expectedBucketOwner: input.options?.expectedBucketOwner,
|
|
81
|
+
onProgress: (input as any).options?.onProgress,
|
|
82
|
+
abortSignal: abortController.signal,
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
if (abortController.signal.aborted) {
|
|
86
|
+
throw new CanceledError({ message: 'Operation was cancelled' });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
await deleteObject(
|
|
90
|
+
{
|
|
91
|
+
...s3Config,
|
|
92
|
+
userAgentValue: getStorageUserAgentValue(StorageAction.Remove),
|
|
93
|
+
abortSignal: abortController.signal,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
Bucket: bucket,
|
|
97
|
+
Key: finalKey,
|
|
98
|
+
ExpectedBucketOwner: input.options?.expectedBucketOwner,
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const result =
|
|
103
|
+
inputType === STORAGE_INPUT_KEY
|
|
104
|
+
? { key: objectKey }
|
|
105
|
+
: { path: objectKey };
|
|
106
|
+
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (abortController.signal.aborted) {
|
|
111
|
+
throw new CanceledError({ message: 'Operation was cancelled' });
|
|
57
112
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
113
|
+
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
@@ -5,6 +5,7 @@ import { Amplify } from '@aws-amplify/core';
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
RemoveInput,
|
|
8
|
+
RemoveOperation,
|
|
8
9
|
RemoveOutput,
|
|
9
10
|
RemoveWithPathInput,
|
|
10
11
|
RemoveWithPathOutput,
|
|
@@ -13,29 +14,33 @@ import {
|
|
|
13
14
|
import { remove as removeInternal } from './internal/remove';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* Remove a file from your S3 bucket.
|
|
17
|
+
* Remove a file or folder from your S3 bucket.
|
|
17
18
|
* @param input - The `RemoveWithPathInput` object.
|
|
18
|
-
* @return
|
|
19
|
+
* @return Operation handle with result promise and cancellation capability.
|
|
19
20
|
* @throws service: `S3Exception` - S3 service errors thrown while while removing the object.
|
|
20
21
|
* @throws validation: `StorageValidationErrorCode` - Validation errors thrown
|
|
21
22
|
* when there is no path or path is empty or path has a leading slash.
|
|
22
23
|
*/
|
|
23
24
|
export function remove(
|
|
24
25
|
input: RemoveWithPathInput,
|
|
25
|
-
):
|
|
26
|
+
): RemoveOperation<RemoveWithPathOutput>;
|
|
26
27
|
/**
|
|
27
28
|
* @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
|
|
28
29
|
* Please use {@link https://docs.amplify.aws/react/build-a-backend/storage/remove | path} instead.
|
|
29
30
|
*
|
|
30
31
|
* Remove a file from your S3 bucket.
|
|
31
32
|
* @param input - The `RemoveInput` object.
|
|
32
|
-
* @return
|
|
33
|
+
* @return Operation handle with result promise and cancellation capability.
|
|
33
34
|
* @throws service: `S3Exception` - S3 service errors thrown while while removing the object
|
|
34
35
|
* @throws validation: `StorageValidationErrorCode` - Validation errors thrown
|
|
35
36
|
* when there is no key or its empty.
|
|
36
37
|
*/
|
|
37
|
-
export function remove(input: RemoveInput):
|
|
38
|
+
export function remove(input: RemoveInput): RemoveOperation<RemoveOutput>;
|
|
38
39
|
|
|
39
40
|
export function remove(input: RemoveInput | RemoveWithPathInput) {
|
|
40
|
-
|
|
41
|
+
if ('key' in input) {
|
|
42
|
+
return removeInternal(Amplify, input);
|
|
43
|
+
} else {
|
|
44
|
+
return removeInternal(Amplify, input);
|
|
45
|
+
}
|
|
41
46
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
RemoveInput,
|
|
11
|
+
RemoveOperation,
|
|
11
12
|
RemoveOutput,
|
|
12
13
|
RemoveWithPathInput,
|
|
13
14
|
RemoveWithPathOutput,
|
|
@@ -15,10 +16,10 @@ import {
|
|
|
15
16
|
import { remove as removeInternal } from '../internal/remove';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
|
-
* Remove a file from your S3 bucket.
|
|
19
|
+
* Remove a file or folder from your S3 bucket.
|
|
19
20
|
* @param input - The `RemoveWithPathInput` object.
|
|
20
21
|
* @param contextSpec - The context spec used to get the Amplify server context.
|
|
21
|
-
* @return
|
|
22
|
+
* @return Operation handle with result promise and cancellation capability.
|
|
22
23
|
* @throws service: `S3Exception` - S3 service errors thrown while while removing the object.
|
|
23
24
|
* @throws validation: `StorageValidationErrorCode` - Validation errors thrown
|
|
24
25
|
* when there is no path or path is empty or path has a leading slash.
|
|
@@ -26,7 +27,7 @@ import { remove as removeInternal } from '../internal/remove';
|
|
|
26
27
|
export function remove(
|
|
27
28
|
contextSpec: AmplifyServer.ContextSpec,
|
|
28
29
|
input: RemoveWithPathInput,
|
|
29
|
-
):
|
|
30
|
+
): RemoveOperation<RemoveWithPathOutput>;
|
|
30
31
|
/**
|
|
31
32
|
* @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
|
|
32
33
|
* Please use {@link https://docs.amplify.aws/react/build-a-backend/storage/remove | path} instead.
|
|
@@ -34,7 +35,7 @@ export function remove(
|
|
|
34
35
|
* Remove a file from your S3 bucket.
|
|
35
36
|
* @param input - The `RemoveInput` object.
|
|
36
37
|
* @param contextSpec - The context spec used to get the Amplify server context.
|
|
37
|
-
* @return
|
|
38
|
+
* @return Operation handle with result promise and cancellation capability.
|
|
38
39
|
* @throws service: `S3Exception` - S3 service errors thrown while while removing the object
|
|
39
40
|
* @throws validation: `StorageValidationErrorCode` - Validation errors thrown
|
|
40
41
|
* when there is no key or its empty.
|
|
@@ -42,11 +43,15 @@ export function remove(
|
|
|
42
43
|
export function remove(
|
|
43
44
|
contextSpec: AmplifyServer.ContextSpec,
|
|
44
45
|
input: RemoveInput,
|
|
45
|
-
):
|
|
46
|
+
): RemoveOperation<RemoveOutput>;
|
|
46
47
|
|
|
47
48
|
export function remove(
|
|
48
49
|
contextSpec: AmplifyServer.ContextSpec,
|
|
49
50
|
input: RemoveInput | RemoveWithPathInput,
|
|
50
51
|
) {
|
|
51
|
-
|
|
52
|
+
if ('key' in input) {
|
|
53
|
+
return removeInternal(getAmplifyServerContext(contextSpec).amplify, input);
|
|
54
|
+
} else {
|
|
55
|
+
return removeInternal(getAmplifyServerContext(contextSpec).amplify, input);
|
|
56
|
+
}
|
|
52
57
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
StorageUploadDataInputWithKey,
|
|
18
18
|
StorageUploadDataInputWithPath,
|
|
19
19
|
} from '../../../types';
|
|
20
|
+
import { NonPausableTransferTask } from '../../../types/common';
|
|
20
21
|
import {
|
|
21
22
|
CopyDestinationWithKeyOptions,
|
|
22
23
|
CopySourceWithKeyOptions,
|
|
@@ -107,9 +108,31 @@ export type RemoveInput = StorageRemoveInputWithKey<RemoveOptions>;
|
|
|
107
108
|
* Input type with path for S3 remove API.
|
|
108
109
|
*/
|
|
109
110
|
export type RemoveWithPathInput = StorageRemoveInputWithPath<
|
|
110
|
-
Omit<RemoveOptions, 'accessLevel'>
|
|
111
|
+
Omit<RemoveOptions, 'accessLevel'> & {
|
|
112
|
+
/** Callback function invoked after each batch completes, providing progress updates with file counts and error details. */
|
|
113
|
+
onProgress?(progress: ProgressInfo): void;
|
|
114
|
+
}
|
|
111
115
|
>;
|
|
112
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Represents an ongoing remove operation with cancellation and state tracking capabilities
|
|
119
|
+
* @template T - The type of the result (RemoveWithPathOutput | RemoveOutput)
|
|
120
|
+
*/
|
|
121
|
+
export interface RemoveOperation<T> extends NonPausableTransferTask<T> {
|
|
122
|
+
then: Promise<T>['then'];
|
|
123
|
+
catch: Promise<T>['catch'];
|
|
124
|
+
finally: Promise<T>['finally'];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface ProgressInfo {
|
|
128
|
+
deleted?: { path: string }[];
|
|
129
|
+
failed?: {
|
|
130
|
+
path: string;
|
|
131
|
+
code: string;
|
|
132
|
+
message: string;
|
|
133
|
+
}[];
|
|
134
|
+
}
|
|
135
|
+
|
|
113
136
|
/**
|
|
114
137
|
* @deprecated Use {@link DownloadDataWithPathInput} instead.
|
|
115
138
|
* Input type for S3 downloadData API.
|