@aws-amplify/storage 6.0.1-preview-testing.64b45b1.0 → 6.0.1-preview-testing.ddb17c0.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/lib/index.d.ts +1 -1
- package/lib/index.js +1 -3
- package/lib/providers/s3/apis/copy.d.ts +2 -3
- package/lib/providers/s3/apis/copy.js +2 -3
- package/lib/providers/s3/apis/downloadData.d.ts +2 -3
- package/lib/providers/s3/apis/downloadData.js +2 -3
- package/lib/providers/s3/apis/getProperties.d.ts +2 -2
- package/lib/providers/s3/apis/getProperties.js +2 -2
- package/lib/providers/s3/apis/getUrl.d.ts +3 -2
- package/lib/providers/s3/apis/getUrl.js +3 -2
- package/lib/providers/s3/apis/list.d.ts +4 -4
- package/lib/providers/s3/apis/remove.d.ts +2 -2
- package/lib/providers/s3/apis/remove.js +2 -2
- package/lib/providers/s3/apis/uploadData/index.d.ts +2 -3
- package/lib/providers/s3/apis/uploadData/index.js +2 -3
- package/lib/providers/s3/types/index.d.ts +1 -1
- package/lib/providers/s3/types/inputs.d.ts +26 -2
- package/lib/providers/s3/types/options.d.ts +37 -24
- package/lib/providers/s3/types/outputs.d.ts +31 -1
- package/lib/providers/s3/utils/client/abortMultipartUpload.d.ts +1 -1
- package/lib/providers/s3/utils/client/completeMultipartUpload.d.ts +1 -1
- package/lib/providers/s3/utils/client/copyObject.d.ts +1 -1
- package/lib/providers/s3/utils/client/createMultipartUpload.d.ts +1 -1
- package/lib/providers/s3/utils/client/deleteObject.d.ts +1 -1
- package/lib/providers/s3/utils/client/getObject.d.ts +1 -1
- package/lib/providers/s3/utils/client/headObject.d.ts +1 -1
- package/lib/providers/s3/utils/client/listObjectsV2.d.ts +1 -1
- package/lib/providers/s3/utils/client/listParts.d.ts +1 -1
- package/lib/providers/s3/utils/client/putObject.d.ts +1 -1
- package/lib/providers/s3/utils/client/uploadPart.d.ts +1 -1
- package/lib/providers/s3/utils/transferTask.js +10 -13
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/common.d.ts +1 -7
- package/lib/types/common.js +0 -9
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +0 -3
- package/lib/types/inputs.d.ts +8 -5
- package/lib/types/options.d.ts +2 -12
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/index.js +0 -1
- package/lib-esm/providers/s3/apis/copy.d.ts +2 -3
- package/lib-esm/providers/s3/apis/copy.js +2 -3
- package/lib-esm/providers/s3/apis/downloadData.d.ts +2 -3
- package/lib-esm/providers/s3/apis/downloadData.js +2 -3
- package/lib-esm/providers/s3/apis/getProperties.d.ts +2 -2
- package/lib-esm/providers/s3/apis/getProperties.js +2 -2
- package/lib-esm/providers/s3/apis/getUrl.d.ts +3 -2
- package/lib-esm/providers/s3/apis/getUrl.js +3 -2
- package/lib-esm/providers/s3/apis/list.d.ts +4 -4
- package/lib-esm/providers/s3/apis/remove.d.ts +2 -2
- package/lib-esm/providers/s3/apis/remove.js +2 -2
- package/lib-esm/providers/s3/apis/uploadData/index.d.ts +2 -3
- package/lib-esm/providers/s3/apis/uploadData/index.js +2 -3
- package/lib-esm/providers/s3/types/index.d.ts +1 -1
- package/lib-esm/providers/s3/types/inputs.d.ts +26 -2
- package/lib-esm/providers/s3/types/options.d.ts +37 -24
- package/lib-esm/providers/s3/types/outputs.d.ts +31 -1
- package/lib-esm/providers/s3/utils/client/abortMultipartUpload.d.ts +1 -1
- package/lib-esm/providers/s3/utils/client/completeMultipartUpload.d.ts +1 -1
- package/lib-esm/providers/s3/utils/client/copyObject.d.ts +1 -1
- package/lib-esm/providers/s3/utils/client/createMultipartUpload.d.ts +1 -1
- package/lib-esm/providers/s3/utils/client/deleteObject.d.ts +1 -1
- package/lib-esm/providers/s3/utils/client/getObject.d.ts +1 -1
- package/lib-esm/providers/s3/utils/client/headObject.d.ts +1 -1
- package/lib-esm/providers/s3/utils/client/listObjectsV2.d.ts +1 -1
- package/lib-esm/providers/s3/utils/client/listParts.d.ts +1 -1
- package/lib-esm/providers/s3/utils/client/putObject.d.ts +1 -1
- package/lib-esm/providers/s3/utils/client/uploadPart.d.ts +1 -1
- package/lib-esm/providers/s3/utils/transferTask.js +10 -13
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/common.d.ts +1 -7
- package/lib-esm/types/common.js +1 -8
- package/lib-esm/types/index.d.ts +1 -1
- package/lib-esm/types/index.js +1 -1
- package/lib-esm/types/inputs.d.ts +8 -5
- package/lib-esm/types/options.d.ts +2 -12
- package/package.json +4 -4
- package/src/index.ts +1 -1
- package/src/providers/s3/apis/copy.ts +4 -4
- package/src/providers/s3/apis/downloadData.ts +3 -4
- package/src/providers/s3/apis/getProperties.ts +3 -3
- package/src/providers/s3/apis/getUrl.ts +5 -4
- package/src/providers/s3/apis/list.ts +4 -4
- package/src/providers/s3/apis/remove.ts +2 -2
- package/src/providers/s3/apis/uploadData/index.ts +3 -4
- package/src/providers/s3/types/index.ts +2 -0
- package/src/providers/s3/types/inputs.ts +31 -1
- package/src/providers/s3/types/options.ts +74 -53
- package/src/providers/s3/types/outputs.ts +33 -3
- package/src/providers/s3/utils/transferTask.ts +10 -14
- package/src/types/common.ts +6 -7
- package/src/types/index.ts +0 -2
- package/src/types/inputs.ts +10 -7
- package/src/types/options.ts +4 -16
|
@@ -14,16 +14,16 @@ type ListApi = {
|
|
|
14
14
|
/**
|
|
15
15
|
* List files with given prefix in pages
|
|
16
16
|
* pageSize defaulted to 1000. Additionally, the result will include a nextToken if there are more items to retrieve.
|
|
17
|
-
* @param
|
|
18
|
-
* @
|
|
17
|
+
* @param input - The ListPaginateInput object.
|
|
18
|
+
* @returns A list of keys and metadata with
|
|
19
19
|
* @throws service: {@link S3Exception} - S3 service errors thrown when checking for existence of bucket
|
|
20
20
|
* @throws validation: {@link StorageValidationErrorCode } - thrown when there are issues with credentials
|
|
21
21
|
*/
|
|
22
22
|
(input?: ListPaginateInput): Promise<ListPaginateOutput>;
|
|
23
23
|
/**
|
|
24
24
|
* List all files from S3. You can set `listAll` to true in `options` to get all the files from S3.
|
|
25
|
-
* @param
|
|
26
|
-
* @
|
|
25
|
+
* @param input - The ListAllInput object.
|
|
26
|
+
* @returns A list of keys and metadata for all objects in path
|
|
27
27
|
* @throws service: {@link S3Exception} - S3 service errors thrown when checking for existence of bucket
|
|
28
28
|
* @throws validation: {@link StorageValidationErrorCode } - thrown when there are issues with credentials
|
|
29
29
|
*/
|
|
@@ -7,8 +7,8 @@ import { remove as removeInternal } from './internal/remove';
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Remove a file from your S3 bucket.
|
|
10
|
-
* @param
|
|
11
|
-
* @return
|
|
10
|
+
* @param input - The RemoveInput object.
|
|
11
|
+
* @return Output containing the removed object key
|
|
12
12
|
* @throws service: {@link S3Exception} - S3 service errors thrown while getting properties
|
|
13
13
|
* @throws validation: {@link StorageValidationErrorCode } - Validation errors thrown
|
|
14
14
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { UploadDataInput, UploadDataOutput } from '../../types';
|
|
4
|
+
import { UploadDataInput, UploadDataOutput, S3Exception } from '../../types';
|
|
5
5
|
import { createUploadTask } from '../../utils';
|
|
6
6
|
import { assertValidationError } from '../../../../errors/utils/assertValidationError';
|
|
7
7
|
import { StorageValidationErrorCode } from '../../../../errors/types/validation';
|
|
@@ -18,9 +18,8 @@ import { getMultipartUploadHandlers } from './multipart';
|
|
|
18
18
|
* * Maximum object size is 5TB.
|
|
19
19
|
* * Maximum object size if the size cannot be determined before upload is 50GB.
|
|
20
20
|
*
|
|
21
|
-
* @param
|
|
22
|
-
*
|
|
23
|
-
* @returns {UploadDataOutput} Cancelable and Resumable task exposing result promise from `result`
|
|
21
|
+
* @param input - The UploadDataInput object.
|
|
22
|
+
* @returns A cancelable and resumable task exposing result promise from `result`
|
|
24
23
|
* property.
|
|
25
24
|
* @throws service: {@link S3Exception} - thrown when checking for existence of the object
|
|
26
25
|
* @throws validation: {@link StorageValidationErrorCode } - Validation errors.
|
|
@@ -18,21 +18,51 @@ import {
|
|
|
18
18
|
RemoveOptions,
|
|
19
19
|
DownloadDataOptions,
|
|
20
20
|
UploadDataOptions,
|
|
21
|
+
CopyDestinationOptions,
|
|
22
|
+
CopySourceOptions,
|
|
21
23
|
} from '../types';
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
// TODO: support use accelerate endpoint option
|
|
26
|
+
/**
|
|
27
|
+
* Input type for S3 copy API.
|
|
28
|
+
*/
|
|
29
|
+
export type CopyInput = StorageCopyInput<
|
|
30
|
+
CopySourceOptions,
|
|
31
|
+
CopyDestinationOptions
|
|
32
|
+
>;
|
|
24
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Input type for S3 getProperties API.
|
|
36
|
+
*/
|
|
25
37
|
export type GetPropertiesInput =
|
|
26
38
|
StorageGetPropertiesInput<GetPropertiesOptions>;
|
|
27
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Input type for S3 getUrl API.
|
|
42
|
+
*/
|
|
28
43
|
export type GetUrlInput = StorageGetUrlInput<GetUrlOptions>;
|
|
29
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Input type for S3 list API. Lists all bucket objects.
|
|
47
|
+
*/
|
|
30
48
|
export type ListAllInput = StorageListInput<ListAllOptions>;
|
|
31
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Input type for S3 list API. Lists bucket objects with pagination.
|
|
52
|
+
*/
|
|
32
53
|
export type ListPaginateInput = StorageListInput<ListPaginateOptions>;
|
|
33
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Input type for S3 remove API.
|
|
57
|
+
*/
|
|
34
58
|
export type RemoveInput = StorageRemoveInput<RemoveOptions>;
|
|
35
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Input type for S3 downloadData API.
|
|
62
|
+
*/
|
|
36
63
|
export type DownloadDataInput = StorageDownloadDataInput<DownloadDataOptions>;
|
|
37
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Input type for S3 uploadData API.
|
|
67
|
+
*/
|
|
38
68
|
export type UploadDataInput = StorageUploadDataInput<UploadDataOptions>;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { StorageAccessLevel } from '@aws-amplify/core';
|
|
4
5
|
// TODO(ashwinkumar6) this uses V5 Credentials, update to V6.
|
|
5
6
|
import { Credentials } from '@aws-sdk/types';
|
|
6
7
|
|
|
7
8
|
import { TransferProgressEvent } from '../../../types';
|
|
8
9
|
import {
|
|
9
|
-
StorageOptions,
|
|
10
10
|
StorageListAllOptions,
|
|
11
11
|
StorageListPaginateOptions,
|
|
12
12
|
} from '../../../types/options';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
* Input options type for S3 Storage operations.
|
|
16
|
-
*/
|
|
17
|
-
export type Options = StorageOptions & {
|
|
14
|
+
type CommonOptions = {
|
|
18
15
|
/**
|
|
19
16
|
* Whether to use accelerate endpoint.
|
|
20
17
|
* @default false
|
|
@@ -22,68 +19,101 @@ export type Options = StorageOptions & {
|
|
|
22
19
|
useAccelerateEndpoint?: boolean;
|
|
23
20
|
};
|
|
24
21
|
|
|
22
|
+
type ReadOptions =
|
|
23
|
+
| { accessLevel?: 'guest' | 'private' }
|
|
24
|
+
| { accessLevel: 'protected'; targetIdentityId?: string };
|
|
25
|
+
|
|
26
|
+
type WriteOptions = {
|
|
27
|
+
accessLevel?: StorageAccessLevel;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Transfer-related options type for S3 downloadData, uploadData APIs.
|
|
32
|
+
*/
|
|
33
|
+
type TransferOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* Callback function tracking the upload/download progress.
|
|
36
|
+
*/
|
|
37
|
+
onProgress?: (event: TransferProgressEvent) => void;
|
|
38
|
+
};
|
|
39
|
+
|
|
25
40
|
/**
|
|
26
41
|
* Input options type for S3 getProperties API.
|
|
27
42
|
*/
|
|
28
|
-
export type GetPropertiesOptions =
|
|
43
|
+
export type GetPropertiesOptions = ReadOptions & CommonOptions;
|
|
29
44
|
|
|
30
45
|
/**
|
|
31
46
|
* Input options type for S3 getProperties API.
|
|
32
47
|
*/
|
|
33
|
-
export type RemoveOptions =
|
|
48
|
+
export type RemoveOptions = WriteOptions & CommonOptions;
|
|
34
49
|
|
|
35
50
|
/**
|
|
36
51
|
* Input options type for S3 list API.
|
|
37
52
|
*/
|
|
38
|
-
export type ListAllOptions = StorageListAllOptions
|
|
53
|
+
export type ListAllOptions = StorageListAllOptions &
|
|
54
|
+
ReadOptions &
|
|
55
|
+
CommonOptions;
|
|
39
56
|
|
|
40
57
|
/**
|
|
41
58
|
* Input options type for S3 list API.
|
|
42
59
|
*/
|
|
43
|
-
export type ListPaginateOptions = StorageListPaginateOptions
|
|
60
|
+
export type ListPaginateOptions = StorageListPaginateOptions &
|
|
61
|
+
ReadOptions &
|
|
62
|
+
CommonOptions;
|
|
44
63
|
|
|
45
64
|
/**
|
|
46
|
-
* Input options type for S3
|
|
65
|
+
* Input options type for S3 getUrl API.
|
|
47
66
|
*/
|
|
48
|
-
export type
|
|
67
|
+
export type GetUrlOptions = ReadOptions &
|
|
68
|
+
CommonOptions & {
|
|
69
|
+
/**
|
|
70
|
+
* Whether to head object to make sure the object existence before downloading.
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
validateObjectExistence?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Number of seconds till the URL expires.
|
|
76
|
+
* @default 900 (15 minutes)
|
|
77
|
+
*/
|
|
78
|
+
expiresIn?: number;
|
|
79
|
+
};
|
|
49
80
|
|
|
50
81
|
/**
|
|
51
|
-
* Input options type for S3
|
|
82
|
+
* Input options type for S3 downloadData API.
|
|
52
83
|
*/
|
|
53
|
-
export type
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
export type DownloadDataOptions = ReadOptions & CommonOptions & TransferOptions;
|
|
85
|
+
|
|
86
|
+
export type UploadDataOptions = WriteOptions &
|
|
87
|
+
CommonOptions &
|
|
88
|
+
TransferOptions & {
|
|
89
|
+
/**
|
|
90
|
+
* The default content-disposition header value of the file when downloading it.
|
|
91
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
|
|
92
|
+
*/
|
|
93
|
+
contentDisposition?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The default content-encoding header value of the file when downloading it.
|
|
96
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
|
|
97
|
+
*/
|
|
98
|
+
contentEncoding?: string;
|
|
99
|
+
/**
|
|
100
|
+
* The default content-type header value of the file when downloading it.
|
|
101
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
|
|
102
|
+
*/
|
|
103
|
+
contentType?: string;
|
|
104
|
+
/**
|
|
105
|
+
* The user-defined metadata for the object uploaded to S3.
|
|
106
|
+
* @see https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html#UserMetadata
|
|
107
|
+
*/
|
|
108
|
+
metadata?: Record<string, string>;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type CopySourceOptions = ReadOptions & {
|
|
112
|
+
key: string;
|
|
64
113
|
};
|
|
65
114
|
|
|
66
|
-
export type
|
|
67
|
-
|
|
68
|
-
* The default content-disposition header value of the file when downloading it.
|
|
69
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
|
|
70
|
-
*/
|
|
71
|
-
contentDisposition?: string;
|
|
72
|
-
/**
|
|
73
|
-
* The default content-encoding header value of the file when downloading it.
|
|
74
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
|
|
75
|
-
*/
|
|
76
|
-
contentEncoding?: string;
|
|
77
|
-
/**
|
|
78
|
-
* The default content-type header value of the file when downloading it.
|
|
79
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
|
|
80
|
-
*/
|
|
81
|
-
contentType?: string;
|
|
82
|
-
/**
|
|
83
|
-
* The user-defined metadata for the object uploaded to S3.
|
|
84
|
-
* @see https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html#UserMetadata
|
|
85
|
-
*/
|
|
86
|
-
metadata?: Record<string, string>;
|
|
115
|
+
export type CopyDestinationOptions = WriteOptions & {
|
|
116
|
+
key: string;
|
|
87
117
|
};
|
|
88
118
|
|
|
89
119
|
/**
|
|
@@ -98,12 +128,3 @@ export type ResolvedS3Config = {
|
|
|
98
128
|
forcePathStyle?: boolean;
|
|
99
129
|
useAccelerateEndpoint?: boolean;
|
|
100
130
|
};
|
|
101
|
-
/**
|
|
102
|
-
* Input options type for S3 downloadData, uploadData APIs.
|
|
103
|
-
*/
|
|
104
|
-
type TransferOptions = Options & {
|
|
105
|
-
/**
|
|
106
|
-
* Callback function tracking the upload/download progress.
|
|
107
|
-
*/
|
|
108
|
-
onProgress?: (event: TransferProgressEvent) => void;
|
|
109
|
-
};
|
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
UploadTask,
|
|
11
11
|
} from '../../../types';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* type for S3 item.
|
|
15
|
+
*/
|
|
13
16
|
export interface Item extends StorageItem {
|
|
14
17
|
/**
|
|
15
18
|
* VersionId used to reference a specific version of the object.
|
|
@@ -21,22 +24,49 @@ export interface Item extends StorageItem {
|
|
|
21
24
|
contentType?: string;
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
/**
|
|
28
|
+
* type for S3 list item.
|
|
29
|
+
*/
|
|
30
|
+
export type ListOutputItem = Omit<StorageItem, 'metadata'>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Output type for S3 downloadData API.
|
|
34
|
+
*/
|
|
24
35
|
export type DownloadDataOutput = DownloadTask<StorageDownloadDataOutput<Item>>;
|
|
25
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Output type for S3 getUrl API.
|
|
39
|
+
*/
|
|
26
40
|
export type GetUrlOutput = StorageGetUrlOutput;
|
|
27
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Output type for S3 uploadData API.
|
|
44
|
+
*/
|
|
28
45
|
export type UploadDataOutput = UploadTask<Item>;
|
|
29
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Output type for S3 getProperties API.
|
|
49
|
+
*/
|
|
30
50
|
export type GetPropertiesOutput = Item;
|
|
31
51
|
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Output type for S3 list API. Lists all bucket objects.
|
|
54
|
+
*/
|
|
34
55
|
export type ListAllOutput = StorageListOutput<ListOutputItem>;
|
|
35
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Output type for S3 list API. Lists bucket objects with pagination.
|
|
59
|
+
*/
|
|
36
60
|
export type ListPaginateOutput = StorageListOutput<ListOutputItem> & {
|
|
37
61
|
nextToken?: string;
|
|
38
62
|
};
|
|
39
63
|
|
|
40
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Output type for S3 copy API.
|
|
66
|
+
*/
|
|
41
67
|
export type CopyOutput = Pick<Item, 'key'>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Output type for S3 remove API.
|
|
71
|
+
*/
|
|
42
72
|
export type RemoveOutput = Pick<Item, 'key'>;
|
|
@@ -19,20 +19,16 @@ const createCancellableTask = <Result>({
|
|
|
19
19
|
job,
|
|
20
20
|
onCancel,
|
|
21
21
|
}: CreateCancellableTaskOptions<Result>): CancellableTask<Result> => {
|
|
22
|
-
const state = TransferTaskState
|
|
22
|
+
const state = 'IN_PROGRESS' as TransferTaskState;
|
|
23
23
|
let abortErrorOverwriteRecord: Error | undefined = undefined;
|
|
24
24
|
const cancelableTask = {
|
|
25
25
|
cancel: (abortErrorOverwrite?: Error) => {
|
|
26
26
|
abortErrorOverwriteRecord = abortErrorOverwrite;
|
|
27
27
|
const { state } = cancelableTask;
|
|
28
|
-
if (
|
|
29
|
-
state === TransferTaskState.CANCELED ||
|
|
30
|
-
state === TransferTaskState.ERROR ||
|
|
31
|
-
state === TransferTaskState.SUCCESS
|
|
32
|
-
) {
|
|
28
|
+
if (state === 'CANCELED' || state === 'ERROR' || state === 'SUCCESS') {
|
|
33
29
|
return;
|
|
34
30
|
}
|
|
35
|
-
cancelableTask.state =
|
|
31
|
+
cancelableTask.state = 'CANCELED';
|
|
36
32
|
onCancel(abortErrorOverwrite);
|
|
37
33
|
},
|
|
38
34
|
state,
|
|
@@ -41,14 +37,14 @@ const createCancellableTask = <Result>({
|
|
|
41
37
|
const wrappedJobPromise = (async () => {
|
|
42
38
|
try {
|
|
43
39
|
const result = await job();
|
|
44
|
-
cancelableTask.state =
|
|
40
|
+
cancelableTask.state = 'SUCCESS';
|
|
45
41
|
return result;
|
|
46
42
|
} catch (e) {
|
|
47
43
|
if (isCancelError(e)) {
|
|
48
|
-
cancelableTask.state =
|
|
44
|
+
cancelableTask.state = 'CANCELED';
|
|
49
45
|
throw abortErrorOverwriteRecord ?? e;
|
|
50
46
|
}
|
|
51
|
-
cancelableTask.state =
|
|
47
|
+
cancelableTask.state = 'ERROR';
|
|
52
48
|
throw e;
|
|
53
49
|
}
|
|
54
50
|
})();
|
|
@@ -83,20 +79,20 @@ export const createUploadTask = <Result>({
|
|
|
83
79
|
const uploadTask = Object.assign(cancellableTask, {
|
|
84
80
|
pause: () => {
|
|
85
81
|
const { state } = uploadTask;
|
|
86
|
-
if (!isMultipartUpload || state !==
|
|
82
|
+
if (!isMultipartUpload || state !== 'IN_PROGRESS') {
|
|
87
83
|
return;
|
|
88
84
|
}
|
|
89
85
|
// @ts-ignore
|
|
90
|
-
uploadTask.state =
|
|
86
|
+
uploadTask.state = 'PAUSED';
|
|
91
87
|
onPause?.();
|
|
92
88
|
},
|
|
93
89
|
resume: () => {
|
|
94
90
|
const { state } = uploadTask;
|
|
95
|
-
if (!isMultipartUpload || state !==
|
|
91
|
+
if (!isMultipartUpload || state !== 'PAUSED') {
|
|
96
92
|
return;
|
|
97
93
|
}
|
|
98
94
|
// @ts-ignore
|
|
99
|
-
uploadTask.state =
|
|
95
|
+
uploadTask.state = 'IN_PROGRESS';
|
|
100
96
|
onResume?.();
|
|
101
97
|
},
|
|
102
98
|
});
|
package/src/types/common.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
4
|
+
export type TransferTaskState =
|
|
5
|
+
| 'IN_PROGRESS'
|
|
6
|
+
| 'PAUSED'
|
|
7
|
+
| 'CANCELED'
|
|
8
|
+
| 'SUCCESS'
|
|
9
|
+
| 'ERROR';
|
|
11
10
|
|
|
12
11
|
export type TransferProgressEvent = {
|
|
13
12
|
transferredBytes: number;
|
package/src/types/index.ts
CHANGED
package/src/types/inputs.ts
CHANGED
|
@@ -5,8 +5,6 @@ import {
|
|
|
5
5
|
StorageOptions,
|
|
6
6
|
StorageListAllOptions,
|
|
7
7
|
StorageListPaginateOptions,
|
|
8
|
-
StorageCopySourceOptions,
|
|
9
|
-
StorageCopyDestinationOptions,
|
|
10
8
|
} from './options';
|
|
11
9
|
|
|
12
10
|
export type StorageOperationInput<Options extends StorageOptions> = {
|
|
@@ -17,8 +15,10 @@ export type StorageOperationInput<Options extends StorageOptions> = {
|
|
|
17
15
|
export type StorageGetPropertiesInput<Options extends StorageOptions> =
|
|
18
16
|
StorageOperationInput<Options>;
|
|
19
17
|
|
|
20
|
-
export type StorageRemoveInput<Options extends StorageOptions> =
|
|
21
|
-
|
|
18
|
+
export type StorageRemoveInput<Options extends StorageOptions> = {
|
|
19
|
+
key: string;
|
|
20
|
+
options?: Options;
|
|
21
|
+
};
|
|
22
22
|
|
|
23
23
|
export type StorageListInput<
|
|
24
24
|
Options extends StorageListAllOptions | StorageListPaginateOptions
|
|
@@ -38,9 +38,12 @@ export type StorageUploadDataInput<Options extends StorageOptions> =
|
|
|
38
38
|
data: StorageUploadDataPayload;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export type StorageCopyInput
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
export type StorageCopyInput<
|
|
42
|
+
SourceOptions extends StorageOptions,
|
|
43
|
+
DestinationOptions extends StorageOptions
|
|
44
|
+
> = {
|
|
45
|
+
source: SourceOptions;
|
|
46
|
+
destination: DestinationOptions;
|
|
44
47
|
};
|
|
45
48
|
|
|
46
49
|
/**
|
package/src/types/options.ts
CHANGED
|
@@ -3,12 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
import { StorageAccessLevel } from '@aws-amplify/core';
|
|
5
5
|
|
|
6
|
-
export type StorageOptions =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
accessLevel: 'protected';
|
|
10
|
-
targetIdentityId?: string;
|
|
11
|
-
};
|
|
6
|
+
export type StorageOptions = {
|
|
7
|
+
accessLevel?: StorageAccessLevel;
|
|
8
|
+
};
|
|
12
9
|
|
|
13
10
|
export type StorageListAllOptions = StorageOptions & {
|
|
14
11
|
listAll: true;
|
|
@@ -20,13 +17,4 @@ export type StorageListPaginateOptions = StorageOptions & {
|
|
|
20
17
|
nextToken?: string;
|
|
21
18
|
};
|
|
22
19
|
|
|
23
|
-
export type StorageRemoveOptions =
|
|
24
|
-
|
|
25
|
-
export type StorageCopySourceOptions = {
|
|
26
|
-
key: string;
|
|
27
|
-
} & StorageOptions;
|
|
28
|
-
|
|
29
|
-
export type StorageCopyDestinationOptions = {
|
|
30
|
-
key: string;
|
|
31
|
-
accessLevel?: StorageAccessLevel;
|
|
32
|
-
};
|
|
20
|
+
export type StorageRemoveOptions = StorageOptions;
|