@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
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { uploadData, downloadData, remove, list, getProperties, copy, getUrl, } from './providers/s3';
|
|
2
2
|
export { UploadDataInput, DownloadDataInput, RemoveInput, ListAllInput, ListPaginateInput, GetPropertiesInput, CopyInput, GetUrlInput, } from './providers/s3/types/inputs';
|
|
3
3
|
export { UploadDataOutput, DownloadDataOutput, RemoveOutput, ListAllOutput, ListPaginateOutput, GetPropertiesOutput, CopyOutput, GetUrlOutput, } from './providers/s3/types/outputs';
|
|
4
|
-
export { TransferProgressEvent
|
|
4
|
+
export { TransferProgressEvent } from './types';
|
|
5
5
|
export { isCancelError } from './errors/CanceledError';
|
|
6
6
|
export { StorageError } from './errors/StorageError';
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.StorageError = exports.isCancelError = exports.
|
|
5
|
+
exports.StorageError = exports.isCancelError = exports.getUrl = exports.copy = exports.getProperties = exports.list = exports.remove = exports.downloadData = exports.uploadData = void 0;
|
|
6
6
|
var s3_1 = require("./providers/s3");
|
|
7
7
|
Object.defineProperty(exports, "uploadData", { enumerable: true, get: function () { return s3_1.uploadData; } });
|
|
8
8
|
Object.defineProperty(exports, "downloadData", { enumerable: true, get: function () { return s3_1.downloadData; } });
|
|
@@ -11,8 +11,6 @@ Object.defineProperty(exports, "list", { enumerable: true, get: function () { re
|
|
|
11
11
|
Object.defineProperty(exports, "getProperties", { enumerable: true, get: function () { return s3_1.getProperties; } });
|
|
12
12
|
Object.defineProperty(exports, "copy", { enumerable: true, get: function () { return s3_1.copy; } });
|
|
13
13
|
Object.defineProperty(exports, "getUrl", { enumerable: true, get: function () { return s3_1.getUrl; } });
|
|
14
|
-
var types_1 = require("./types");
|
|
15
|
-
Object.defineProperty(exports, "TransferTaskState", { enumerable: true, get: function () { return types_1.TransferTaskState; } });
|
|
16
14
|
// TODO[AllanZhengYP]: support isCancelError in Node.js with node-fetch
|
|
17
15
|
var CanceledError_1 = require("./errors/CanceledError");
|
|
18
16
|
Object.defineProperty(exports, "isCancelError", { enumerable: true, get: function () { return CanceledError_1.isCancelError; } });
|
|
@@ -3,9 +3,8 @@ import { CopyInput, CopyOutput } from '../types';
|
|
|
3
3
|
* Copy an object from a source object to a new object within the same bucket. Can optionally copy files across
|
|
4
4
|
* different level or identityId (if source object's level is 'protected').
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
8
|
-
* @return {Promise<CopyOutput>} Promise resolves upon successful copy of the object.
|
|
6
|
+
* @param input - The CopyInput object.
|
|
7
|
+
* @returns Output containing the destination key.
|
|
9
8
|
* @throws service: {@link S3Exception} - Thrown when checking for existence of the object
|
|
10
9
|
* @throws validation: {@link StorageValidationErrorCode } - Thrown when
|
|
11
10
|
* source or destination key are not defined.
|
|
@@ -10,9 +10,8 @@ var copy_1 = require("./internal/copy");
|
|
|
10
10
|
* Copy an object from a source object to a new object within the same bucket. Can optionally copy files across
|
|
11
11
|
* different level or identityId (if source object's level is 'protected').
|
|
12
12
|
*
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
15
|
-
* @return {Promise<CopyOutput>} Promise resolves upon successful copy of the object.
|
|
13
|
+
* @param input - The CopyInput object.
|
|
14
|
+
* @returns Output containing the destination key.
|
|
16
15
|
* @throws service: {@link S3Exception} - Thrown when checking for existence of the object
|
|
17
16
|
* @throws validation: {@link StorageValidationErrorCode } - Thrown when
|
|
18
17
|
* source or destination key are not defined.
|
|
@@ -2,9 +2,8 @@ import { DownloadDataInput, DownloadDataOutput } from '../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Download S3 object data to memory
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
6
|
-
*
|
|
7
|
-
* @returns {DownloadDataOutput} Cancelable task exposing result promise from `result` property.
|
|
5
|
+
* @param input - The DownloadDataInput object.
|
|
6
|
+
* @returns A cancelable task exposing result promise from `result` property.
|
|
8
7
|
* @throws service: {@link S3Exception} - thrown when checking for existence of the object
|
|
9
8
|
* @throws validation: {@link StorageValidationErrorCode } - Validation errors
|
|
10
9
|
*
|
|
@@ -11,9 +11,8 @@ var client_1 = require("../utils/client");
|
|
|
11
11
|
/**
|
|
12
12
|
* Download S3 object data to memory
|
|
13
13
|
*
|
|
14
|
-
* @param
|
|
15
|
-
*
|
|
16
|
-
* @returns {DownloadDataOutput} Cancelable task exposing result promise from `result` property.
|
|
14
|
+
* @param input - The DownloadDataInput object.
|
|
15
|
+
* @returns A cancelable task exposing result promise from `result` property.
|
|
17
16
|
* @throws service: {@link S3Exception} - thrown when checking for existence of the object
|
|
18
17
|
* @throws validation: {@link StorageValidationErrorCode } - Validation errors
|
|
19
18
|
*
|
|
@@ -3,8 +3,8 @@ import { GetPropertiesOutput, GetPropertiesInput } from '../types';
|
|
|
3
3
|
* Gets the properties of a file. The properties include S3 system metadata and
|
|
4
4
|
* the user metadata that was provided when uploading the file.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @returns
|
|
6
|
+
* @param input - The GetPropertiesInput object.
|
|
7
|
+
* @returns Requested object properties.
|
|
8
8
|
* @throws A {@link S3Exception} when the underlying S3 service returned error.
|
|
9
9
|
* @throws A {@link StorageValidationErrorCode} when API call parameters are invalid.
|
|
10
10
|
*/
|
|
@@ -9,8 +9,8 @@ var getProperties_1 = require("./internal/getProperties");
|
|
|
9
9
|
* Gets the properties of a file. The properties include S3 system metadata and
|
|
10
10
|
* the user metadata that was provided when uploading the file.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
13
|
-
* @returns
|
|
12
|
+
* @param input - The GetPropertiesInput object.
|
|
13
|
+
* @returns Requested object properties.
|
|
14
14
|
* @throws A {@link S3Exception} when the underlying S3 service returned error.
|
|
15
15
|
* @throws A {@link StorageValidationErrorCode} when API call parameters are invalid.
|
|
16
16
|
*/
|
|
@@ -3,12 +3,13 @@ import { GetUrlInput, GetUrlOutput } from '../types';
|
|
|
3
3
|
* Get a temporary presigned URL to download the specified S3 object.
|
|
4
4
|
* The presigned URL expires when the associated role used to sign the request expires or
|
|
5
5
|
* the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
|
|
6
|
+
*
|
|
6
7
|
* By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
|
|
7
8
|
* to true, this method will verify the given object already exists in S3 before returning a presigned
|
|
8
9
|
* URL, and will throw {@link StorageError} if the object does not exist.
|
|
9
10
|
*
|
|
10
|
-
* @param
|
|
11
|
-
* @
|
|
11
|
+
* @param input - The GetUrlInput object.
|
|
12
|
+
* @returns Presigned URL and timestamp when the URL MAY expire.
|
|
12
13
|
* @throws service: {@link S3Exception} - thrown when checking for existence of the object
|
|
13
14
|
* @throws validation: {@link StorageValidationErrorCode } - Validation errors
|
|
14
15
|
* thrown either username or key are not defined.
|
|
@@ -9,12 +9,13 @@ var getUrl_1 = require("./internal/getUrl");
|
|
|
9
9
|
* Get a temporary presigned URL to download the specified S3 object.
|
|
10
10
|
* The presigned URL expires when the associated role used to sign the request expires or
|
|
11
11
|
* the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
|
|
12
|
+
*
|
|
12
13
|
* By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
|
|
13
14
|
* to true, this method will verify the given object already exists in S3 before returning a presigned
|
|
14
15
|
* URL, and will throw {@link StorageError} if the object does not exist.
|
|
15
16
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @
|
|
17
|
+
* @param input - The GetUrlInput object.
|
|
18
|
+
* @returns Presigned URL and timestamp when the URL MAY expire.
|
|
18
19
|
* @throws service: {@link S3Exception} - thrown when checking for existence of the object
|
|
19
20
|
* @throws validation: {@link StorageValidationErrorCode } - Validation errors
|
|
20
21
|
* thrown either username or key are not defined.
|
|
@@ -3,16 +3,16 @@ type ListApi = {
|
|
|
3
3
|
/**
|
|
4
4
|
* List files with given prefix in pages
|
|
5
5
|
* pageSize defaulted to 1000. Additionally, the result will include a nextToken if there are more items to retrieve.
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
6
|
+
* @param input - The ListPaginateInput object.
|
|
7
|
+
* @returns A list of keys and metadata with
|
|
8
8
|
* @throws service: {@link S3Exception} - S3 service errors thrown when checking for existence of bucket
|
|
9
9
|
* @throws validation: {@link StorageValidationErrorCode } - thrown when there are issues with credentials
|
|
10
10
|
*/
|
|
11
11
|
(input?: ListPaginateInput): Promise<ListPaginateOutput>;
|
|
12
12
|
/**
|
|
13
13
|
* List all files from S3. You can set `listAll` to true in `options` to get all the files from S3.
|
|
14
|
-
* @param
|
|
15
|
-
* @
|
|
14
|
+
* @param input - The ListAllInput object.
|
|
15
|
+
* @returns A list of keys and metadata for all objects in path
|
|
16
16
|
* @throws service: {@link S3Exception} - S3 service errors thrown when checking for existence of bucket
|
|
17
17
|
* @throws validation: {@link StorageValidationErrorCode } - thrown when there are issues with credentials
|
|
18
18
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RemoveInput, RemoveOutput } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Remove a file from your S3 bucket.
|
|
4
|
-
* @param
|
|
5
|
-
* @return
|
|
4
|
+
* @param input - The RemoveInput object.
|
|
5
|
+
* @return Output containing the removed object key
|
|
6
6
|
* @throws service: {@link S3Exception} - S3 service errors thrown while getting properties
|
|
7
7
|
* @throws validation: {@link StorageValidationErrorCode } - Validation errors thrown
|
|
8
8
|
*/
|
|
@@ -7,8 +7,8 @@ var core_1 = require("@aws-amplify/core");
|
|
|
7
7
|
var remove_1 = require("./internal/remove");
|
|
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
|
*/
|
|
@@ -7,9 +7,8 @@ import { UploadDataInput, UploadDataOutput } from '../../types';
|
|
|
7
7
|
* * Maximum object size is 5TB.
|
|
8
8
|
* * Maximum object size if the size cannot be determined before upload is 50GB.
|
|
9
9
|
*
|
|
10
|
-
* @param
|
|
11
|
-
*
|
|
12
|
-
* @returns {UploadDataOutput} Cancelable and Resumable task exposing result promise from `result`
|
|
10
|
+
* @param input - The UploadDataInput object.
|
|
11
|
+
* @returns A cancelable and resumable task exposing result promise from `result`
|
|
13
12
|
* property.
|
|
14
13
|
* @throws service: {@link S3Exception} - thrown when checking for existence of the object
|
|
15
14
|
* @throws validation: {@link StorageValidationErrorCode } - Validation errors.
|
|
@@ -18,9 +18,8 @@ var multipart_1 = require("./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.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { GetUrlOptions, UploadDataOptions, GetPropertiesOptions, ListAllOptions, ListPaginateOptions, RemoveOptions, DownloadDataOptions, } from './options';
|
|
1
|
+
export { GetUrlOptions, UploadDataOptions, GetPropertiesOptions, ListAllOptions, ListPaginateOptions, RemoveOptions, DownloadDataOptions, CopyDestinationOptions, CopySourceOptions, } from './options';
|
|
2
2
|
export { DownloadDataOutput, GetUrlOutput, UploadDataOutput, ListOutputItem, ListAllOutput, ListPaginateOutput, GetPropertiesOutput, CopyOutput, RemoveOutput, } from './outputs';
|
|
3
3
|
export { CopyInput, GetPropertiesInput, GetUrlInput, ListAllInput, ListPaginateInput, RemoveInput, DownloadDataInput, UploadDataInput, } from './inputs';
|
|
4
4
|
export { S3Exception } from './errors';
|
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
import { StorageCopyInput, StorageGetPropertiesInput, StorageGetUrlInput, StorageListInput, StorageRemoveInput, StorageDownloadDataInput, StorageUploadDataInput } from '../../../types';
|
|
2
|
-
import { GetPropertiesOptions, GetUrlOptions, ListAllOptions, ListPaginateOptions, RemoveOptions, DownloadDataOptions, UploadDataOptions } from '../types';
|
|
3
|
-
|
|
2
|
+
import { GetPropertiesOptions, GetUrlOptions, ListAllOptions, ListPaginateOptions, RemoveOptions, DownloadDataOptions, UploadDataOptions, CopyDestinationOptions, CopySourceOptions } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Input type for S3 copy API.
|
|
5
|
+
*/
|
|
6
|
+
export type CopyInput = StorageCopyInput<CopySourceOptions, CopyDestinationOptions>;
|
|
7
|
+
/**
|
|
8
|
+
* Input type for S3 getProperties API.
|
|
9
|
+
*/
|
|
4
10
|
export type GetPropertiesInput = StorageGetPropertiesInput<GetPropertiesOptions>;
|
|
11
|
+
/**
|
|
12
|
+
* Input type for S3 getUrl API.
|
|
13
|
+
*/
|
|
5
14
|
export type GetUrlInput = StorageGetUrlInput<GetUrlOptions>;
|
|
15
|
+
/**
|
|
16
|
+
* Input type for S3 list API. Lists all bucket objects.
|
|
17
|
+
*/
|
|
6
18
|
export type ListAllInput = StorageListInput<ListAllOptions>;
|
|
19
|
+
/**
|
|
20
|
+
* Input type for S3 list API. Lists bucket objects with pagination.
|
|
21
|
+
*/
|
|
7
22
|
export type ListPaginateInput = StorageListInput<ListPaginateOptions>;
|
|
23
|
+
/**
|
|
24
|
+
* Input type for S3 remove API.
|
|
25
|
+
*/
|
|
8
26
|
export type RemoveInput = StorageRemoveInput<RemoveOptions>;
|
|
27
|
+
/**
|
|
28
|
+
* Input type for S3 downloadData API.
|
|
29
|
+
*/
|
|
9
30
|
export type DownloadDataInput = StorageDownloadDataInput<DownloadDataOptions>;
|
|
31
|
+
/**
|
|
32
|
+
* Input type for S3 uploadData API.
|
|
33
|
+
*/
|
|
10
34
|
export type UploadDataInput = StorageUploadDataInput<UploadDataOptions>;
|
|
@@ -1,40 +1,52 @@
|
|
|
1
|
+
import { StorageAccessLevel } from '@aws-amplify/core';
|
|
1
2
|
import { Credentials } from '@aws-sdk/types';
|
|
2
3
|
import { TransferProgressEvent } from '../../../types';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
* Input options type for S3 Storage operations.
|
|
6
|
-
*/
|
|
7
|
-
export type Options = StorageOptions & {
|
|
4
|
+
import { StorageListAllOptions, StorageListPaginateOptions } from '../../../types/options';
|
|
5
|
+
type CommonOptions = {
|
|
8
6
|
/**
|
|
9
7
|
* Whether to use accelerate endpoint.
|
|
10
8
|
* @default false
|
|
11
9
|
*/
|
|
12
10
|
useAccelerateEndpoint?: boolean;
|
|
13
11
|
};
|
|
12
|
+
type ReadOptions = {
|
|
13
|
+
accessLevel?: 'guest' | 'private';
|
|
14
|
+
} | {
|
|
15
|
+
accessLevel: 'protected';
|
|
16
|
+
targetIdentityId?: string;
|
|
17
|
+
};
|
|
18
|
+
type WriteOptions = {
|
|
19
|
+
accessLevel?: StorageAccessLevel;
|
|
20
|
+
};
|
|
14
21
|
/**
|
|
15
|
-
*
|
|
22
|
+
* Transfer-related options type for S3 downloadData, uploadData APIs.
|
|
16
23
|
*/
|
|
17
|
-
|
|
24
|
+
type TransferOptions = {
|
|
25
|
+
/**
|
|
26
|
+
* Callback function tracking the upload/download progress.
|
|
27
|
+
*/
|
|
28
|
+
onProgress?: (event: TransferProgressEvent) => void;
|
|
29
|
+
};
|
|
18
30
|
/**
|
|
19
31
|
* Input options type for S3 getProperties API.
|
|
20
32
|
*/
|
|
21
|
-
export type
|
|
33
|
+
export type GetPropertiesOptions = ReadOptions & CommonOptions;
|
|
22
34
|
/**
|
|
23
|
-
* Input options type for S3
|
|
35
|
+
* Input options type for S3 getProperties API.
|
|
24
36
|
*/
|
|
25
|
-
export type
|
|
37
|
+
export type RemoveOptions = WriteOptions & CommonOptions;
|
|
26
38
|
/**
|
|
27
39
|
* Input options type for S3 list API.
|
|
28
40
|
*/
|
|
29
|
-
export type
|
|
41
|
+
export type ListAllOptions = StorageListAllOptions & ReadOptions & CommonOptions;
|
|
30
42
|
/**
|
|
31
|
-
* Input options type for S3
|
|
43
|
+
* Input options type for S3 list API.
|
|
32
44
|
*/
|
|
33
|
-
export type
|
|
45
|
+
export type ListPaginateOptions = StorageListPaginateOptions & ReadOptions & CommonOptions;
|
|
34
46
|
/**
|
|
35
47
|
* Input options type for S3 getUrl API.
|
|
36
48
|
*/
|
|
37
|
-
export type GetUrlOptions =
|
|
49
|
+
export type GetUrlOptions = ReadOptions & CommonOptions & {
|
|
38
50
|
/**
|
|
39
51
|
* Whether to head object to make sure the object existence before downloading.
|
|
40
52
|
* @default false
|
|
@@ -46,7 +58,11 @@ export type GetUrlOptions = Options & {
|
|
|
46
58
|
*/
|
|
47
59
|
expiresIn?: number;
|
|
48
60
|
};
|
|
49
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Input options type for S3 downloadData API.
|
|
63
|
+
*/
|
|
64
|
+
export type DownloadDataOptions = ReadOptions & CommonOptions & TransferOptions;
|
|
65
|
+
export type UploadDataOptions = WriteOptions & CommonOptions & TransferOptions & {
|
|
50
66
|
/**
|
|
51
67
|
* The default content-disposition header value of the file when downloading it.
|
|
52
68
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
|
|
@@ -68,6 +84,12 @@ export type UploadDataOptions = Omit<TransferOptions, 'targetIdentityId'> & {
|
|
|
68
84
|
*/
|
|
69
85
|
metadata?: Record<string, string>;
|
|
70
86
|
};
|
|
87
|
+
export type CopySourceOptions = ReadOptions & {
|
|
88
|
+
key: string;
|
|
89
|
+
};
|
|
90
|
+
export type CopyDestinationOptions = WriteOptions & {
|
|
91
|
+
key: string;
|
|
92
|
+
};
|
|
71
93
|
/**
|
|
72
94
|
* Internal only type for S3 API handlers' config parameter.
|
|
73
95
|
*
|
|
@@ -80,13 +102,4 @@ export type ResolvedS3Config = {
|
|
|
80
102
|
forcePathStyle?: boolean;
|
|
81
103
|
useAccelerateEndpoint?: boolean;
|
|
82
104
|
};
|
|
83
|
-
/**
|
|
84
|
-
* Input options type for S3 downloadData, uploadData APIs.
|
|
85
|
-
*/
|
|
86
|
-
type TransferOptions = Options & {
|
|
87
|
-
/**
|
|
88
|
-
* Callback function tracking the upload/download progress.
|
|
89
|
-
*/
|
|
90
|
-
onProgress?: (event: TransferProgressEvent) => void;
|
|
91
|
-
};
|
|
92
105
|
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { StorageDownloadDataOutput, StorageGetUrlOutput, StorageItem, StorageListOutput, DownloadTask, UploadTask } from '../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* type for S3 item.
|
|
4
|
+
*/
|
|
2
5
|
export interface Item extends StorageItem {
|
|
3
6
|
/**
|
|
4
7
|
* VersionId used to reference a specific version of the object.
|
|
@@ -9,14 +12,41 @@ export interface Item extends StorageItem {
|
|
|
9
12
|
*/
|
|
10
13
|
contentType?: string;
|
|
11
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* type for S3 list item.
|
|
17
|
+
*/
|
|
18
|
+
export type ListOutputItem = Omit<StorageItem, 'metadata'>;
|
|
19
|
+
/**
|
|
20
|
+
* Output type for S3 downloadData API.
|
|
21
|
+
*/
|
|
12
22
|
export type DownloadDataOutput = DownloadTask<StorageDownloadDataOutput<Item>>;
|
|
23
|
+
/**
|
|
24
|
+
* Output type for S3 getUrl API.
|
|
25
|
+
*/
|
|
13
26
|
export type GetUrlOutput = StorageGetUrlOutput;
|
|
27
|
+
/**
|
|
28
|
+
* Output type for S3 uploadData API.
|
|
29
|
+
*/
|
|
14
30
|
export type UploadDataOutput = UploadTask<Item>;
|
|
31
|
+
/**
|
|
32
|
+
* Output type for S3 getProperties API.
|
|
33
|
+
*/
|
|
15
34
|
export type GetPropertiesOutput = Item;
|
|
16
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Output type for S3 list API. Lists all bucket objects.
|
|
37
|
+
*/
|
|
17
38
|
export type ListAllOutput = StorageListOutput<ListOutputItem>;
|
|
39
|
+
/**
|
|
40
|
+
* Output type for S3 list API. Lists bucket objects with pagination.
|
|
41
|
+
*/
|
|
18
42
|
export type ListPaginateOutput = StorageListOutput<ListOutputItem> & {
|
|
19
43
|
nextToken?: string;
|
|
20
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Output type for S3 copy API.
|
|
47
|
+
*/
|
|
21
48
|
export type CopyOutput = Pick<Item, 'key'>;
|
|
49
|
+
/**
|
|
50
|
+
* Output type for S3 remove API.
|
|
51
|
+
*/
|
|
22
52
|
export type RemoveOutput = Pick<Item, 'key'>;
|
|
@@ -17,7 +17,7 @@ export declare const abortMultipartUpload: (config: {
|
|
|
17
17
|
useAccelerateEndpoint?: boolean | undefined;
|
|
18
18
|
uriEscapePath?: boolean | undefined;
|
|
19
19
|
} & {
|
|
20
|
-
credentials: import("@aws-sdk/types").
|
|
20
|
+
credentials: import("@aws-sdk/types").AwsCredentialIdentity | (() => Promise<import("@aws-sdk/types").AwsCredentialIdentity>);
|
|
21
21
|
maxAttempts?: number | undefined;
|
|
22
22
|
abortSignal?: AbortSignal | undefined;
|
|
23
23
|
region: string;
|
|
@@ -16,7 +16,7 @@ export declare const completeMultipartUpload: (config: {
|
|
|
16
16
|
useAccelerateEndpoint?: boolean | undefined;
|
|
17
17
|
uriEscapePath?: boolean | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
credentials: import("@aws-
|
|
19
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | (() => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
20
20
|
maxAttempts?: number | undefined;
|
|
21
21
|
abortSignal?: AbortSignal | undefined;
|
|
22
22
|
region: string;
|
|
@@ -16,7 +16,7 @@ export declare const copyObject: (config: {
|
|
|
16
16
|
useAccelerateEndpoint?: boolean | undefined;
|
|
17
17
|
uriEscapePath?: boolean | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
credentials: import("@aws-
|
|
19
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | (() => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
20
20
|
maxAttempts?: number | undefined;
|
|
21
21
|
abortSignal?: AbortSignal | undefined;
|
|
22
22
|
region: string;
|
|
@@ -17,7 +17,7 @@ export declare const createMultipartUpload: (config: {
|
|
|
17
17
|
useAccelerateEndpoint?: boolean | undefined;
|
|
18
18
|
uriEscapePath?: boolean | undefined;
|
|
19
19
|
} & {
|
|
20
|
-
credentials: import("@aws-
|
|
20
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | (() => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
21
21
|
maxAttempts?: number | undefined;
|
|
22
22
|
abortSignal?: AbortSignal | undefined;
|
|
23
23
|
region: string;
|
|
@@ -16,7 +16,7 @@ export declare const deleteObject: (config: {
|
|
|
16
16
|
useAccelerateEndpoint?: boolean | undefined;
|
|
17
17
|
uriEscapePath?: boolean | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
credentials: import("@aws-
|
|
19
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | (() => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
20
20
|
maxAttempts?: number | undefined;
|
|
21
21
|
abortSignal?: AbortSignal | undefined;
|
|
22
22
|
region: string;
|
|
@@ -17,7 +17,7 @@ export declare const getObject: (config: {
|
|
|
17
17
|
useAccelerateEndpoint?: boolean | undefined;
|
|
18
18
|
uriEscapePath?: boolean | undefined;
|
|
19
19
|
} & {
|
|
20
|
-
credentials: import("@aws-
|
|
20
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | (() => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
21
21
|
maxAttempts?: number | undefined;
|
|
22
22
|
abortSignal?: AbortSignal | undefined;
|
|
23
23
|
region: string;
|
|
@@ -16,7 +16,7 @@ export declare const headObject: (config: {
|
|
|
16
16
|
useAccelerateEndpoint?: boolean | undefined;
|
|
17
17
|
uriEscapePath?: boolean | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
credentials: import("@aws-
|
|
19
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | (() => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
20
20
|
maxAttempts?: number | undefined;
|
|
21
21
|
abortSignal?: AbortSignal | undefined;
|
|
22
22
|
region: string;
|
|
@@ -16,7 +16,7 @@ export declare const listObjectsV2: (config: {
|
|
|
16
16
|
useAccelerateEndpoint?: boolean | undefined;
|
|
17
17
|
uriEscapePath?: boolean | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
credentials: import("@aws-
|
|
19
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | (() => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
20
20
|
maxAttempts?: number | undefined;
|
|
21
21
|
abortSignal?: AbortSignal | undefined;
|
|
22
22
|
region: string;
|
|
@@ -16,7 +16,7 @@ export declare const listParts: (config: {
|
|
|
16
16
|
useAccelerateEndpoint?: boolean | undefined;
|
|
17
17
|
uriEscapePath?: boolean | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
credentials: import("@aws-
|
|
19
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | (() => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
20
20
|
maxAttempts?: number | undefined;
|
|
21
21
|
abortSignal?: AbortSignal | undefined;
|
|
22
22
|
region: string;
|
|
@@ -16,7 +16,7 @@ export declare const putObject: (config: {
|
|
|
16
16
|
useAccelerateEndpoint?: boolean | undefined;
|
|
17
17
|
uriEscapePath?: boolean | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
credentials: import("@aws-
|
|
19
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | (() => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
20
20
|
maxAttempts?: number | undefined;
|
|
21
21
|
abortSignal?: AbortSignal | undefined;
|
|
22
22
|
region: string;
|
|
@@ -16,7 +16,7 @@ export declare const uploadPart: (config: {
|
|
|
16
16
|
useAccelerateEndpoint?: boolean | undefined;
|
|
17
17
|
uriEscapePath?: boolean | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
credentials: import("@aws-
|
|
19
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | (() => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
20
20
|
maxAttempts?: number | undefined;
|
|
21
21
|
abortSignal?: AbortSignal | undefined;
|
|
22
22
|
region: string;
|
|
@@ -5,21 +5,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.createUploadTask = exports.createDownloadTask = void 0;
|
|
6
6
|
var tslib_1 = require("tslib");
|
|
7
7
|
var CanceledError_1 = require("../../../errors/CanceledError");
|
|
8
|
-
var common_1 = require("../../../types/common");
|
|
9
8
|
var createCancellableTask = function (_a) {
|
|
10
9
|
var job = _a.job, onCancel = _a.onCancel;
|
|
11
|
-
var state =
|
|
10
|
+
var state = 'IN_PROGRESS';
|
|
12
11
|
var abortErrorOverwriteRecord = undefined;
|
|
13
12
|
var cancelableTask = {
|
|
14
13
|
cancel: function (abortErrorOverwrite) {
|
|
15
14
|
abortErrorOverwriteRecord = abortErrorOverwrite;
|
|
16
15
|
var state = cancelableTask.state;
|
|
17
|
-
if (state ===
|
|
18
|
-
state === common_1.TransferTaskState.ERROR ||
|
|
19
|
-
state === common_1.TransferTaskState.SUCCESS) {
|
|
16
|
+
if (state === 'CANCELED' || state === 'ERROR' || state === 'SUCCESS') {
|
|
20
17
|
return;
|
|
21
18
|
}
|
|
22
|
-
cancelableTask.state =
|
|
19
|
+
cancelableTask.state = 'CANCELED';
|
|
23
20
|
onCancel(abortErrorOverwrite);
|
|
24
21
|
},
|
|
25
22
|
state: state,
|
|
@@ -33,15 +30,15 @@ var createCancellableTask = function (_a) {
|
|
|
33
30
|
return [4 /*yield*/, job()];
|
|
34
31
|
case 1:
|
|
35
32
|
result = _a.sent();
|
|
36
|
-
cancelableTask.state =
|
|
33
|
+
cancelableTask.state = 'SUCCESS';
|
|
37
34
|
return [2 /*return*/, result];
|
|
38
35
|
case 2:
|
|
39
36
|
e_1 = _a.sent();
|
|
40
37
|
if ((0, CanceledError_1.isCancelError)(e_1)) {
|
|
41
|
-
cancelableTask.state =
|
|
38
|
+
cancelableTask.state = 'CANCELED';
|
|
42
39
|
throw abortErrorOverwriteRecord !== null && abortErrorOverwriteRecord !== void 0 ? abortErrorOverwriteRecord : e_1;
|
|
43
40
|
}
|
|
44
|
-
cancelableTask.state =
|
|
41
|
+
cancelableTask.state = 'ERROR';
|
|
45
42
|
throw e_1;
|
|
46
43
|
case 3: return [2 /*return*/];
|
|
47
44
|
}
|
|
@@ -61,20 +58,20 @@ var createUploadTask = function (_a) {
|
|
|
61
58
|
var uploadTask = Object.assign(cancellableTask, {
|
|
62
59
|
pause: function () {
|
|
63
60
|
var state = uploadTask.state;
|
|
64
|
-
if (!isMultipartUpload || state !==
|
|
61
|
+
if (!isMultipartUpload || state !== 'IN_PROGRESS') {
|
|
65
62
|
return;
|
|
66
63
|
}
|
|
67
64
|
// @ts-ignore
|
|
68
|
-
uploadTask.state =
|
|
65
|
+
uploadTask.state = 'PAUSED';
|
|
69
66
|
onPause === null || onPause === void 0 ? void 0 : onPause();
|
|
70
67
|
},
|
|
71
68
|
resume: function () {
|
|
72
69
|
var state = uploadTask.state;
|
|
73
|
-
if (!isMultipartUpload || state !==
|
|
70
|
+
if (!isMultipartUpload || state !== 'PAUSED') {
|
|
74
71
|
return;
|
|
75
72
|
}
|
|
76
73
|
// @ts-ignore
|
|
77
|
-
uploadTask.state =
|
|
74
|
+
uploadTask.state = 'IN_PROGRESS';
|
|
78
75
|
onResume === null || onResume === void 0 ? void 0 : onResume();
|
|
79
76
|
},
|
|
80
77
|
});
|