@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
|
@@ -6,12 +6,63 @@ import {
|
|
|
6
6
|
getAmplifyServerContext,
|
|
7
7
|
} from '@aws-amplify/core/internals/adapter-core';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
GetUrlInput,
|
|
11
|
+
GetUrlInputKey,
|
|
12
|
+
GetUrlInputPath,
|
|
13
|
+
GetUrlOutput,
|
|
14
|
+
} from '../../types';
|
|
10
15
|
import { getUrl as getUrlInternal } from '../internal/getUrl';
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
interface GetUrl {
|
|
18
|
+
/**
|
|
19
|
+
* Get a temporary presigned URL to download the specified S3 object.
|
|
20
|
+
* The presigned URL expires when the associated role used to sign the request expires or
|
|
21
|
+
* the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
|
|
22
|
+
*
|
|
23
|
+
* By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
|
|
24
|
+
* to true, this method will verify the given object already exists in S3 before returning a presigned
|
|
25
|
+
* URL, and will throw `StorageError` if the object does not exist.
|
|
26
|
+
*
|
|
27
|
+
* @param contextSpec - The isolated server context.
|
|
28
|
+
* @param input - The `GetUrlInputPath` object.
|
|
29
|
+
* @returns Presigned URL and timestamp when the URL MAY expire.
|
|
30
|
+
* @throws service: `S3Exception` - thrown when checking for existence of the object
|
|
31
|
+
* @throws validation: `StorageValidationErrorCode` - Validation errors
|
|
32
|
+
* thrown either username or key are not defined.
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
(
|
|
36
|
+
contextSpec: AmplifyServer.ContextSpec,
|
|
37
|
+
input: GetUrlInputPath,
|
|
38
|
+
): Promise<GetUrlOutput>;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
|
|
41
|
+
* Please use {@link https://docs.amplify.aws/javascript/build-a-backend/storage/download/#generate-a-download-url | path} instead.
|
|
42
|
+
*
|
|
43
|
+
* Get a temporary presigned URL to download the specified S3 object.
|
|
44
|
+
* The presigned URL expires when the associated role used to sign the request expires or
|
|
45
|
+
* the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
|
|
46
|
+
*
|
|
47
|
+
* By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
|
|
48
|
+
* to true, this method will verify the given object already exists in S3 before returning a presigned
|
|
49
|
+
* URL, and will throw `StorageError` if the object does not exist.
|
|
50
|
+
*
|
|
51
|
+
* @param contextSpec - The isolated server context.
|
|
52
|
+
* @param input - The `GetUrlInputKey` object.
|
|
53
|
+
* @returns Presigned URL and timestamp when the URL MAY expire.
|
|
54
|
+
* @throws service: `S3Exception` - thrown when checking for existence of the object
|
|
55
|
+
* @throws validation: `StorageValidationErrorCode` - Validation errors
|
|
56
|
+
* thrown either username or key are not defined.
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
(
|
|
60
|
+
contextSpec: AmplifyServer.ContextSpec,
|
|
61
|
+
input: GetUrlInputKey,
|
|
62
|
+
): Promise<GetUrlOutput>;
|
|
63
|
+
}
|
|
64
|
+
export const getUrl: GetUrl = async (
|
|
13
65
|
contextSpec: AmplifyServer.ContextSpec,
|
|
14
66
|
input: GetUrlInput,
|
|
15
|
-
): Promise<GetUrlOutput> =>
|
|
16
|
-
|
|
17
|
-
};
|
|
67
|
+
): Promise<GetUrlOutput> =>
|
|
68
|
+
getUrlInternal(getAmplifyServerContext(contextSpec).amplify, input);
|
|
@@ -6,12 +6,53 @@ import {
|
|
|
6
6
|
getAmplifyServerContext,
|
|
7
7
|
} from '@aws-amplify/core/internals/adapter-core';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
RemoveInput,
|
|
11
|
+
RemoveInputKey,
|
|
12
|
+
RemoveInputPath,
|
|
13
|
+
RemoveOutput,
|
|
14
|
+
RemoveOutputKey,
|
|
15
|
+
RemoveOutputPath,
|
|
16
|
+
} from '../../types';
|
|
10
17
|
import { remove as removeInternal } from '../internal/remove';
|
|
11
18
|
|
|
12
|
-
|
|
19
|
+
interface RemoveApi {
|
|
20
|
+
/**
|
|
21
|
+
* Remove a file from your S3 bucket.
|
|
22
|
+
* @param input - The `RemoveInputPath` object.
|
|
23
|
+
* @param contextSpec - The context spec used to get the Amplify server context.
|
|
24
|
+
* @return Output containing the removed object path.
|
|
25
|
+
* @throws service: `S3Exception` - S3 service errors thrown while while removing the object.
|
|
26
|
+
* @throws validation: `StorageValidationErrorCode` - Validation errors thrown
|
|
27
|
+
* when there is no path or path is empty or path has a leading slash.
|
|
28
|
+
*/
|
|
29
|
+
(
|
|
30
|
+
contextSpec: AmplifyServer.ContextSpec,
|
|
31
|
+
input: RemoveInputPath,
|
|
32
|
+
): Promise<RemoveOutputPath>;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
|
|
35
|
+
* Please use {@link https://docs.amplify.aws/react/build-a-backend/storage/remove | path} instead.
|
|
36
|
+
*
|
|
37
|
+
* Remove a file from your S3 bucket.
|
|
38
|
+
* @param input - The `RemoveInputKey` object.
|
|
39
|
+
* @param contextSpec - The context spec used to get the Amplify server context.
|
|
40
|
+
* @return Output containing the removed object key
|
|
41
|
+
* @throws service: `S3Exception` - S3 service errors thrown while while removing the object
|
|
42
|
+
* @throws validation: `StorageValidationErrorCode` - Validation errors thrown
|
|
43
|
+
* when there is no key or its empty.
|
|
44
|
+
*/
|
|
45
|
+
(
|
|
46
|
+
contextSpec: AmplifyServer.ContextSpec,
|
|
47
|
+
input: RemoveInputKey,
|
|
48
|
+
): Promise<RemoveOutputKey>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const remove: RemoveApi = <Output extends RemoveOutput>(
|
|
13
52
|
contextSpec: AmplifyServer.ContextSpec,
|
|
14
53
|
input: RemoveInput,
|
|
15
|
-
): Promise<
|
|
16
|
-
|
|
17
|
-
|
|
54
|
+
): Promise<Output> =>
|
|
55
|
+
removeInternal(
|
|
56
|
+
getAmplifyServerContext(contextSpec).amplify,
|
|
57
|
+
input,
|
|
58
|
+
) as Promise<Output>;
|
|
@@ -6,7 +6,7 @@ import { StorageAction } from '@aws-amplify/core/internals/utils';
|
|
|
6
6
|
|
|
7
7
|
import { UploadDataInput } from '../../../types';
|
|
8
8
|
import { resolveS3ConfigAndInput } from '../../../utils';
|
|
9
|
-
import {
|
|
9
|
+
import { ItemKey as S3Item } from '../../../types/outputs';
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_ACCESS_LEVEL,
|
|
12
12
|
DEFAULT_QUEUE_SIZE,
|
|
@@ -6,7 +6,7 @@ import { StorageAction } from '@aws-amplify/core/internals/utils';
|
|
|
6
6
|
|
|
7
7
|
import { UploadDataInput } from '../../types';
|
|
8
8
|
import { calculateContentMd5, resolveS3ConfigAndInput } from '../../utils';
|
|
9
|
-
import {
|
|
9
|
+
import { ItemKey as S3Item } from '../../types/outputs';
|
|
10
10
|
import { putObject } from '../../utils/client';
|
|
11
11
|
import { getStorageUserAgentValue } from '../../utils/userAgent';
|
|
12
12
|
|
|
@@ -2,35 +2,56 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export {
|
|
5
|
-
|
|
5
|
+
GetUrlOptionsKey,
|
|
6
|
+
GetUrlOptionsPath,
|
|
6
7
|
UploadDataOptions,
|
|
7
|
-
|
|
8
|
+
GetPropertiesOptionsKey,
|
|
9
|
+
GetPropertiesOptionsPath,
|
|
8
10
|
ListAllOptions,
|
|
9
11
|
ListPaginateOptions,
|
|
10
12
|
RemoveOptions,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
DownloadDataOptionsPath,
|
|
14
|
+
DownloadDataOptionsKey,
|
|
15
|
+
CopyDestinationOptionsKey,
|
|
16
|
+
CopySourceOptionsKey,
|
|
14
17
|
} from './options';
|
|
15
18
|
export {
|
|
16
19
|
DownloadDataOutput,
|
|
20
|
+
DownloadDataOutputKey,
|
|
21
|
+
DownloadDataOutputPath,
|
|
17
22
|
GetUrlOutput,
|
|
18
23
|
UploadDataOutput,
|
|
19
24
|
ListOutputItem,
|
|
20
25
|
ListAllOutput,
|
|
21
26
|
ListPaginateOutput,
|
|
22
27
|
GetPropertiesOutput,
|
|
28
|
+
GetPropertiesOutputKey,
|
|
29
|
+
GetPropertiesOutputPath,
|
|
23
30
|
CopyOutput,
|
|
31
|
+
CopyOutputKey,
|
|
32
|
+
CopyOutputPath,
|
|
24
33
|
RemoveOutput,
|
|
34
|
+
RemoveOutputKey,
|
|
35
|
+
RemoveOutputPath,
|
|
25
36
|
} from './outputs';
|
|
26
37
|
export {
|
|
27
38
|
CopyInput,
|
|
39
|
+
CopyInputKey,
|
|
40
|
+
CopyInputPath,
|
|
28
41
|
GetPropertiesInput,
|
|
42
|
+
GetPropertiesInputKey,
|
|
43
|
+
GetPropertiesInputPath,
|
|
29
44
|
GetUrlInput,
|
|
45
|
+
GetUrlInputKey,
|
|
46
|
+
GetUrlInputPath,
|
|
30
47
|
ListAllInput,
|
|
31
48
|
ListPaginateInput,
|
|
49
|
+
RemoveInputKey,
|
|
50
|
+
RemoveInputPath,
|
|
32
51
|
RemoveInput,
|
|
33
52
|
DownloadDataInput,
|
|
53
|
+
DownloadDataInputKey,
|
|
54
|
+
DownloadDataInputPath,
|
|
34
55
|
UploadDataInput,
|
|
35
56
|
} from './inputs';
|
|
36
57
|
export { S3Exception } from './errors';
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { StrictUnion } from '@aws-amplify/core/internals/utils';
|
|
5
|
+
|
|
4
6
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
StorageCopyInputKey,
|
|
8
|
+
StorageCopyInputPath,
|
|
9
|
+
StorageDownloadDataInputKey,
|
|
10
|
+
StorageDownloadDataInputPath,
|
|
11
|
+
StorageGetPropertiesInputKey,
|
|
12
|
+
StorageGetPropertiesInputPath,
|
|
13
|
+
StorageGetUrlInputKey,
|
|
14
|
+
StorageGetUrlInputPath,
|
|
9
15
|
StorageListInput,
|
|
10
|
-
|
|
16
|
+
StorageRemoveInputKey,
|
|
17
|
+
StorageRemoveInputPath,
|
|
11
18
|
StorageUploadDataInput,
|
|
12
19
|
} from '../../../types';
|
|
13
20
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
CopyDestinationOptionsKey,
|
|
22
|
+
CopySourceOptionsKey,
|
|
23
|
+
DownloadDataOptionsKey,
|
|
24
|
+
DownloadDataOptionsPath,
|
|
25
|
+
GetPropertiesOptionsKey,
|
|
26
|
+
GetPropertiesOptionsPath,
|
|
27
|
+
GetUrlOptionsKey,
|
|
28
|
+
GetUrlOptionsPath,
|
|
19
29
|
ListAllOptions,
|
|
20
30
|
ListPaginateOptions,
|
|
21
31
|
RemoveOptions,
|
|
@@ -26,21 +36,36 @@ import {
|
|
|
26
36
|
/**
|
|
27
37
|
* Input type for S3 copy API.
|
|
28
38
|
*/
|
|
29
|
-
export type CopyInput =
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
export type CopyInput = CopyInputKey | CopyInputPath;
|
|
40
|
+
|
|
41
|
+
/** @deprecated Use {@link CopyInputPath} instead. */
|
|
42
|
+
export type CopyInputKey = StorageCopyInputKey<
|
|
43
|
+
CopySourceOptionsKey,
|
|
44
|
+
CopyDestinationOptionsKey
|
|
32
45
|
>;
|
|
46
|
+
export type CopyInputPath = StorageCopyInputPath;
|
|
33
47
|
|
|
34
48
|
/**
|
|
35
49
|
* Input type for S3 getProperties API.
|
|
36
50
|
*/
|
|
37
|
-
export type GetPropertiesInput =
|
|
38
|
-
|
|
51
|
+
export type GetPropertiesInput = StrictUnion<
|
|
52
|
+
GetPropertiesInputKey | GetPropertiesInputPath
|
|
53
|
+
>;
|
|
54
|
+
|
|
55
|
+
/** @deprecated Use {@link GetPropertiesInputPath} instead. */
|
|
56
|
+
export type GetPropertiesInputKey =
|
|
57
|
+
StorageGetPropertiesInputKey<GetPropertiesOptionsKey>;
|
|
58
|
+
export type GetPropertiesInputPath =
|
|
59
|
+
StorageGetPropertiesInputPath<GetPropertiesOptionsPath>;
|
|
39
60
|
|
|
40
61
|
/**
|
|
41
62
|
* Input type for S3 getUrl API.
|
|
42
63
|
*/
|
|
43
|
-
export type GetUrlInput =
|
|
64
|
+
export type GetUrlInput = StrictUnion<GetUrlInputKey | GetUrlInputPath>;
|
|
65
|
+
|
|
66
|
+
/** @deprecated Use {@link GetUrlInputPath} instead. */
|
|
67
|
+
export type GetUrlInputKey = StorageGetUrlInputKey<GetUrlOptionsKey>;
|
|
68
|
+
export type GetUrlInputPath = StorageGetUrlInputPath<GetUrlOptionsPath>;
|
|
44
69
|
|
|
45
70
|
/**
|
|
46
71
|
* Input type for S3 list API. Lists all bucket objects.
|
|
@@ -52,15 +77,36 @@ export type ListAllInput = StorageListInput<ListAllOptions>;
|
|
|
52
77
|
*/
|
|
53
78
|
export type ListPaginateInput = StorageListInput<ListPaginateOptions>;
|
|
54
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated Use {@link RemoveInputPath} instead.
|
|
82
|
+
* Input type with key for S3 remove API.
|
|
83
|
+
*/
|
|
84
|
+
export type RemoveInputKey = StorageRemoveInputKey<RemoveOptions>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Input type with path for S3 remove API.
|
|
88
|
+
*/
|
|
89
|
+
export type RemoveInputPath = StorageRemoveInputPath<
|
|
90
|
+
Omit<RemoveOptions, 'accessLevel'>
|
|
91
|
+
>;
|
|
92
|
+
|
|
55
93
|
/**
|
|
56
94
|
* Input type for S3 remove API.
|
|
57
95
|
*/
|
|
58
|
-
export type RemoveInput =
|
|
96
|
+
export type RemoveInput = StrictUnion<RemoveInputKey | RemoveInputPath>;
|
|
59
97
|
|
|
60
98
|
/**
|
|
61
99
|
* Input type for S3 downloadData API.
|
|
62
100
|
*/
|
|
63
|
-
export type DownloadDataInput =
|
|
101
|
+
export type DownloadDataInput = StrictUnion<
|
|
102
|
+
DownloadDataInputKey | DownloadDataInputPath
|
|
103
|
+
>;
|
|
104
|
+
|
|
105
|
+
/** @deprecated Use {@link DownloadDataInputPath} instead. */
|
|
106
|
+
export type DownloadDataInputKey =
|
|
107
|
+
StorageDownloadDataInputKey<DownloadDataOptionsKey>;
|
|
108
|
+
export type DownloadDataInputPath =
|
|
109
|
+
StorageDownloadDataInputPath<DownloadDataOptionsPath>;
|
|
64
110
|
|
|
65
111
|
/**
|
|
66
112
|
* Input type for S3 uploadData API.
|
|
@@ -18,11 +18,22 @@ interface CommonOptions {
|
|
|
18
18
|
useAccelerateEndpoint?: boolean;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/** @deprecated This may be removed in the next major version. */
|
|
21
22
|
type ReadOptions =
|
|
22
|
-
| {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
| {
|
|
24
|
+
/** @deprecated This may be removed in the next major version. */
|
|
25
|
+
accessLevel?: 'guest' | 'private';
|
|
26
|
+
}
|
|
27
|
+
| {
|
|
28
|
+
/** @deprecated This may be removed in the next major version. */
|
|
29
|
+
accessLevel: 'protected';
|
|
30
|
+
/** @deprecated This may be removed in the next major version. */
|
|
31
|
+
targetIdentityId?: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** @deprecated This may be removed in the next major version. */
|
|
25
35
|
interface WriteOptions {
|
|
36
|
+
/** @deprecated This may be removed in the next major version. */
|
|
26
37
|
accessLevel?: StorageAccessLevel;
|
|
27
38
|
}
|
|
28
39
|
|
|
@@ -46,7 +57,9 @@ interface TransferOptions {
|
|
|
46
57
|
/**
|
|
47
58
|
* Input options type for S3 getProperties API.
|
|
48
59
|
*/
|
|
49
|
-
|
|
60
|
+
/** @deprecated Use {@link GetPropertiesOptionsPath} instead. */
|
|
61
|
+
export type GetPropertiesOptionsKey = ReadOptions & CommonOptions;
|
|
62
|
+
export type GetPropertiesOptionsPath = CommonOptions;
|
|
50
63
|
|
|
51
64
|
/**
|
|
52
65
|
* Input options type for S3 getProperties API.
|
|
@@ -70,28 +83,34 @@ export type ListPaginateOptions = StorageListPaginateOptions &
|
|
|
70
83
|
/**
|
|
71
84
|
* Input options type for S3 getUrl API.
|
|
72
85
|
*/
|
|
73
|
-
export type GetUrlOptions =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
export type GetUrlOptions = CommonOptions & {
|
|
87
|
+
/**
|
|
88
|
+
* Whether to head object to make sure the object existence before downloading.
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
validateObjectExistence?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Number of seconds till the URL expires.
|
|
94
|
+
* @default 900 (15 minutes)
|
|
95
|
+
*/
|
|
96
|
+
expiresIn?: number;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** @deprecated Use {@link GetUrlOptionsPath} instead. */
|
|
100
|
+
export type GetUrlOptionsKey = ReadOptions & GetUrlOptions;
|
|
101
|
+
export type GetUrlOptionsPath = GetUrlOptions;
|
|
86
102
|
|
|
87
103
|
/**
|
|
88
104
|
* Input options type for S3 downloadData API.
|
|
89
105
|
*/
|
|
90
|
-
export type DownloadDataOptions =
|
|
91
|
-
CommonOptions &
|
|
106
|
+
export type DownloadDataOptions = CommonOptions &
|
|
92
107
|
TransferOptions &
|
|
93
108
|
BytesRangeOptions;
|
|
94
109
|
|
|
110
|
+
/** @deprecated Use {@link DownloadDataOptionsPath} instead. */
|
|
111
|
+
export type DownloadDataOptionsKey = ReadOptions & DownloadDataOptions;
|
|
112
|
+
export type DownloadDataOptionsPath = DownloadDataOptions;
|
|
113
|
+
|
|
95
114
|
export type UploadDataOptions = WriteOptions &
|
|
96
115
|
CommonOptions &
|
|
97
116
|
TransferOptions & {
|
|
@@ -117,11 +136,15 @@ export type UploadDataOptions = WriteOptions &
|
|
|
117
136
|
metadata?: Record<string, string>;
|
|
118
137
|
};
|
|
119
138
|
|
|
120
|
-
|
|
139
|
+
/** @deprecated This may be removed in the next major version. */
|
|
140
|
+
export type CopySourceOptionsKey = ReadOptions & {
|
|
141
|
+
/** @deprecated This may be removed in the next major version. */
|
|
121
142
|
key: string;
|
|
122
143
|
};
|
|
123
144
|
|
|
124
|
-
|
|
145
|
+
/** @deprecated This may be removed in the next major version. */
|
|
146
|
+
export type CopyDestinationOptionsKey = WriteOptions & {
|
|
147
|
+
/** @deprecated This may be removed in the next major version. */
|
|
125
148
|
key: string;
|
|
126
149
|
};
|
|
127
150
|
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { StrictUnion } from '@aws-amplify/core/internals/utils';
|
|
5
|
+
|
|
4
6
|
import {
|
|
5
7
|
DownloadTask,
|
|
6
8
|
StorageDownloadDataOutput,
|
|
7
9
|
StorageGetUrlOutput,
|
|
8
|
-
|
|
10
|
+
StorageItemKey,
|
|
11
|
+
StorageItemPath,
|
|
9
12
|
StorageListOutput,
|
|
10
13
|
UploadTask,
|
|
11
14
|
} from '../../../types';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
|
-
* type for S3 item.
|
|
17
|
+
* Base type for an S3 item.
|
|
15
18
|
*/
|
|
16
|
-
export interface
|
|
19
|
+
export interface ItemBase {
|
|
17
20
|
/**
|
|
18
21
|
* VersionId used to reference a specific version of the object.
|
|
19
22
|
*/
|
|
@@ -24,15 +27,29 @@ export interface Item extends StorageItem {
|
|
|
24
27
|
contentType?: string;
|
|
25
28
|
}
|
|
26
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Use {@link ItemPath} instead.
|
|
32
|
+
*/
|
|
33
|
+
export type ItemKey = ItemBase & StorageItemKey;
|
|
34
|
+
export type ItemPath = ItemBase & StorageItemPath;
|
|
35
|
+
|
|
27
36
|
/**
|
|
28
37
|
* type for S3 list item.
|
|
29
38
|
*/
|
|
30
|
-
export type ListOutputItem = Omit<
|
|
39
|
+
export type ListOutputItem = Omit<ItemKey, 'metadata'>;
|
|
40
|
+
|
|
41
|
+
/** @deprecated Use {@link DownloadDataOutputPath} instead. */
|
|
42
|
+
export type DownloadDataOutputKey = DownloadTask<
|
|
43
|
+
StorageDownloadDataOutput<ItemKey>
|
|
44
|
+
>;
|
|
45
|
+
export type DownloadDataOutputPath = DownloadTask<
|
|
46
|
+
StorageDownloadDataOutput<ItemPath>
|
|
47
|
+
>;
|
|
31
48
|
|
|
32
49
|
/**
|
|
33
50
|
* Output type for S3 downloadData API.
|
|
34
51
|
*/
|
|
35
|
-
export type DownloadDataOutput =
|
|
52
|
+
export type DownloadDataOutput = DownloadDataOutputKey | DownloadDataOutputPath;
|
|
36
53
|
|
|
37
54
|
/**
|
|
38
55
|
* Output type for S3 getUrl API.
|
|
@@ -42,12 +59,18 @@ export type GetUrlOutput = StorageGetUrlOutput;
|
|
|
42
59
|
/**
|
|
43
60
|
* Output type for S3 uploadData API.
|
|
44
61
|
*/
|
|
45
|
-
export type UploadDataOutput = UploadTask<
|
|
62
|
+
export type UploadDataOutput = UploadTask<ItemKey>;
|
|
63
|
+
|
|
64
|
+
/** @deprecated Use {@link GetPropertiesOutputPath} instead. */
|
|
65
|
+
export type GetPropertiesOutputKey = ItemKey;
|
|
66
|
+
export type GetPropertiesOutputPath = ItemPath;
|
|
46
67
|
|
|
47
68
|
/**
|
|
48
69
|
* Output type for S3 getProperties API.
|
|
49
70
|
*/
|
|
50
|
-
export type GetPropertiesOutput =
|
|
71
|
+
export type GetPropertiesOutput =
|
|
72
|
+
| GetPropertiesOutputKey
|
|
73
|
+
| GetPropertiesOutputPath;
|
|
51
74
|
|
|
52
75
|
/**
|
|
53
76
|
* Output type for S3 list API. Lists all bucket objects.
|
|
@@ -62,11 +85,25 @@ export type ListPaginateOutput = StorageListOutput<ListOutputItem> & {
|
|
|
62
85
|
};
|
|
63
86
|
|
|
64
87
|
/**
|
|
65
|
-
*
|
|
88
|
+
* @deprecated Use {@link CopyOutputPath} instead.
|
|
66
89
|
*/
|
|
67
|
-
export type
|
|
90
|
+
export type CopyOutputKey = Pick<ItemKey, 'key'>;
|
|
91
|
+
export type CopyOutputPath = Pick<ItemPath, 'path'>;
|
|
92
|
+
|
|
93
|
+
export type CopyOutput = StrictUnion<CopyOutputKey | CopyOutputPath>;
|
|
68
94
|
|
|
69
95
|
/**
|
|
70
96
|
* Output type for S3 remove API.
|
|
71
97
|
*/
|
|
72
|
-
export type RemoveOutput =
|
|
98
|
+
export type RemoveOutput = StrictUnion<RemoveOutputKey | RemoveOutputPath>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @deprecated Use {@link RemoveOutputPath} instead.
|
|
102
|
+
* Output helper type with key for S3 remove API.
|
|
103
|
+
*/
|
|
104
|
+
export type RemoveOutputKey = Pick<ItemKey, 'key'>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Output helper type with path for S3 remove API.
|
|
108
|
+
*/
|
|
109
|
+
export type RemoveOutputPath = Pick<ItemPath, 'path'>;
|
|
@@ -4,3 +4,5 @@
|
|
|
4
4
|
export { calculateContentMd5 } from './md5';
|
|
5
5
|
export { resolveS3ConfigAndInput } from './resolveS3ConfigAndInput';
|
|
6
6
|
export { createDownloadTask, createUploadTask } from './transferTask';
|
|
7
|
+
export { validateStorageOperationInput } from './validateStorageOperationInput';
|
|
8
|
+
export { isInputWithPath } from './isInputWithPath';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
StorageOperationInputPath,
|
|
6
|
+
StorageOperationInputType,
|
|
7
|
+
} from '../../../types/inputs';
|
|
8
|
+
|
|
9
|
+
export const isInputWithPath = (
|
|
10
|
+
input: StorageOperationInputType,
|
|
11
|
+
): input is StorageOperationInputPath => {
|
|
12
|
+
return input.path !== undefined;
|
|
13
|
+
};
|
|
@@ -5,7 +5,6 @@ import { AmplifyClassV6, StorageAccessLevel } from '@aws-amplify/core';
|
|
|
5
5
|
|
|
6
6
|
import { assertValidationError } from '../../../errors/utils/assertValidationError';
|
|
7
7
|
import { StorageValidationErrorCode } from '../../../errors/types/validation';
|
|
8
|
-
import { StorageError } from '../../../errors/StorageError';
|
|
9
8
|
import { resolvePrefix as defaultPrefixResolver } from '../../../utils/resolvePrefix';
|
|
10
9
|
import { ResolvedS3Config } from '../types/options';
|
|
11
10
|
|
|
@@ -22,6 +21,7 @@ interface ResolvedS3ConfigAndInput {
|
|
|
22
21
|
bucket: string;
|
|
23
22
|
keyPrefix: string;
|
|
24
23
|
isObjectLockEnabled?: boolean;
|
|
24
|
+
identityId?: string;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -30,7 +30,7 @@ interface ResolvedS3ConfigAndInput {
|
|
|
30
30
|
* @param {AmplifyClassV6} amplify The Amplify instance.
|
|
31
31
|
* @param {S3ApiOptions} apiOptions The input options for S3 provider.
|
|
32
32
|
* @returns {Promise<ResolvedS3ConfigAndInput>} The resolved common input options for S3 API handlers.
|
|
33
|
-
* @throws A
|
|
33
|
+
* @throws A `StorageError` with `error.name` from `StorageValidationErrorCode` indicating invalid
|
|
34
34
|
* configurations or Amplify library options.
|
|
35
35
|
*
|
|
36
36
|
* @internal
|
|
@@ -84,6 +84,7 @@ export const resolveS3ConfigAndInput = async (
|
|
|
84
84
|
},
|
|
85
85
|
bucket,
|
|
86
86
|
keyPrefix,
|
|
87
|
+
identityId,
|
|
87
88
|
isObjectLockEnabled,
|
|
88
89
|
};
|
|
89
90
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { StorageOperationInputType as Input } from '../../../types/inputs';
|
|
5
|
+
import { assertValidationError } from '../../../errors/utils/assertValidationError';
|
|
6
|
+
import { StorageValidationErrorCode } from '../../../errors/types/validation';
|
|
7
|
+
|
|
8
|
+
import { isInputWithPath } from './isInputWithPath';
|
|
9
|
+
import { STORAGE_INPUT_KEY, STORAGE_INPUT_PATH } from './constants';
|
|
10
|
+
|
|
11
|
+
export const validateStorageOperationInput = (
|
|
12
|
+
input: Input,
|
|
13
|
+
identityId?: string,
|
|
14
|
+
) => {
|
|
15
|
+
assertValidationError(
|
|
16
|
+
// Key present without a path
|
|
17
|
+
(!!(input as Input).key && !(input as Input).path) ||
|
|
18
|
+
// Path present without a key
|
|
19
|
+
(!(input as Input).key && !!(input as Input).path),
|
|
20
|
+
StorageValidationErrorCode.InvalidStorageOperationInput,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
if (isInputWithPath(input)) {
|
|
24
|
+
const { path } = input;
|
|
25
|
+
const objectKey = typeof path === 'string' ? path : path({ identityId });
|
|
26
|
+
|
|
27
|
+
assertValidationError(
|
|
28
|
+
!objectKey.startsWith('/'),
|
|
29
|
+
StorageValidationErrorCode.InvalidStoragePathInput,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
inputType: STORAGE_INPUT_PATH,
|
|
34
|
+
objectKey,
|
|
35
|
+
};
|
|
36
|
+
} else {
|
|
37
|
+
return { inputType: STORAGE_INPUT_KEY, objectKey: input.key };
|
|
38
|
+
}
|
|
39
|
+
};
|
package/src/types/index.ts
CHANGED
|
@@ -10,12 +10,17 @@ export {
|
|
|
10
10
|
export {
|
|
11
11
|
StorageOperationInput,
|
|
12
12
|
StorageListInput,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
StorageGetPropertiesInputKey,
|
|
14
|
+
StorageGetPropertiesInputPath,
|
|
15
|
+
StorageRemoveInputPath,
|
|
16
|
+
StorageRemoveInputKey,
|
|
17
|
+
StorageDownloadDataInputKey,
|
|
18
|
+
StorageDownloadDataInputPath,
|
|
16
19
|
StorageUploadDataInput,
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
StorageCopyInputKey,
|
|
21
|
+
StorageCopyInputPath,
|
|
22
|
+
StorageGetUrlInputKey,
|
|
23
|
+
StorageGetUrlInputPath,
|
|
19
24
|
StorageUploadDataPayload,
|
|
20
25
|
} from './inputs';
|
|
21
26
|
export {
|
|
@@ -26,6 +31,8 @@ export {
|
|
|
26
31
|
} from './options';
|
|
27
32
|
export {
|
|
28
33
|
StorageItem,
|
|
34
|
+
StorageItemKey,
|
|
35
|
+
StorageItemPath,
|
|
29
36
|
StorageListOutput,
|
|
30
37
|
StorageDownloadDataOutput,
|
|
31
38
|
StorageGetUrlOutput,
|