@aws-amplify/storage 4.5.11-unstable.2 → 4.5.11
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/CHANGELOG.md +8 -0
- package/package.json +3 -3
- package/lib/Storage.d.ts +0 -107
- package/lib/common/S3ClientUtils.d.ts +0 -33
- package/lib/common/StorageConstants.d.ts +0 -4
- package/lib/common/StorageErrorStrings.d.ts +0 -16
- package/lib/common/StorageUtils.d.ts +0 -4
- package/lib/index.d.ts +0 -9
- package/lib/providers/AWSS3Provider.d.ts +0 -87
- package/lib/providers/AWSS3ProviderManagedUpload.d.ts +0 -41
- package/lib/providers/AWSS3UploadTask.d.ts +0 -107
- package/lib/providers/axios-http-handler.d.ts +0 -40
- package/lib/providers/index.d.ts +0 -1
- package/lib/types/AWSS3Provider.d.ts +0 -120
- package/lib/types/Provider.d.ts +0 -22
- package/lib/types/Storage.d.ts +0 -79
- package/lib/types/index.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.5.11](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.5.10...@aws-amplify/storage@4.5.11) (2022-10-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-amplify/storage
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [4.5.10](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.5.9...@aws-amplify/storage@4.5.10) (2022-10-14)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @aws-amplify/storage
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/storage",
|
|
3
|
-
"version": "4.5.11
|
|
3
|
+
"version": "4.5.11",
|
|
4
4
|
"description": "Storage category of aws-amplify",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://aws-amplify.github.io/",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@aws-amplify/core": "4.7.9
|
|
44
|
+
"@aws-amplify/core": "4.7.9",
|
|
45
45
|
"@aws-sdk/client-s3": "3.6.1",
|
|
46
46
|
"@aws-sdk/s3-request-presigner": "3.6.1",
|
|
47
47
|
"@aws-sdk/util-create-request": "3.6.1",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@types/sinon": "^7.5.1"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "be5bf2dc68c9c011c3876f003c14bc98b392c82d"
|
|
102
102
|
}
|
package/lib/Storage.d.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { StorageCopySource, StorageCopyDestination, StorageGetConfig, StorageProvider, StoragePutConfig, StorageRemoveConfig, StorageListConfig, StorageCopyConfig, StorageGetOutput, StoragePutOutput, StorageRemoveOutput, StorageListOutput, StorageCopyOutput, UploadTask } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Provide storage methods to use AWS S3
|
|
4
|
-
*/
|
|
5
|
-
export declare class Storage {
|
|
6
|
-
/**
|
|
7
|
-
* @private
|
|
8
|
-
*/
|
|
9
|
-
private _config;
|
|
10
|
-
private _pluggables;
|
|
11
|
-
/**
|
|
12
|
-
* Similar to the API module. This weak map allows users to cancel their in-flight request made using the Storage
|
|
13
|
-
* module. For every get or put request, a unique cancel token will be generated and injected to it's underlying
|
|
14
|
-
* AxiosHttpHandler. This map maintains a mapping of Request to CancelTokenSource. When .cancel is invoked, it will
|
|
15
|
-
* attempt to retrieve it's corresponding cancelTokenSource and cancel the in-flight request.
|
|
16
|
-
*/
|
|
17
|
-
private _cancelTokenSourceMap;
|
|
18
|
-
/**
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
vault: Storage;
|
|
22
|
-
/**
|
|
23
|
-
* Initialize Storage
|
|
24
|
-
* @param {Object} config - Configuration object for storage
|
|
25
|
-
*/
|
|
26
|
-
constructor();
|
|
27
|
-
getModuleName(): string;
|
|
28
|
-
/**
|
|
29
|
-
* add plugin into Storage category
|
|
30
|
-
* @param {Object} pluggable - an instance of the plugin
|
|
31
|
-
*/
|
|
32
|
-
addPluggable(pluggable: StorageProvider): {};
|
|
33
|
-
/**
|
|
34
|
-
* Get the plugin object
|
|
35
|
-
* @param providerName - the name of the plugin
|
|
36
|
-
*/
|
|
37
|
-
getPluggable(providerName: string): StorageProvider;
|
|
38
|
-
/**
|
|
39
|
-
* Remove the plugin object
|
|
40
|
-
* @param providerName - the name of the plugin
|
|
41
|
-
*/
|
|
42
|
-
removePluggable(providerName: string): void;
|
|
43
|
-
/**
|
|
44
|
-
* Configure Storage
|
|
45
|
-
* @param {Object} config - Configuration object for storage
|
|
46
|
-
* @return {Object} - Current configuration
|
|
47
|
-
*/
|
|
48
|
-
configure(config?: any): any;
|
|
49
|
-
private getCancellableTokenSource;
|
|
50
|
-
private updateRequestToBeCancellable;
|
|
51
|
-
private isUploadTask;
|
|
52
|
-
/**
|
|
53
|
-
* Cancels an inflight request
|
|
54
|
-
*
|
|
55
|
-
* @param request - The request to cancel
|
|
56
|
-
* @param [message] - A message to include in the cancelation exception
|
|
57
|
-
*/
|
|
58
|
-
cancel(request: UploadTask, message?: string): Promise<boolean>;
|
|
59
|
-
cancel(request: Promise<any>, message?: string): void;
|
|
60
|
-
/**
|
|
61
|
-
* Copies a file from src to dest.
|
|
62
|
-
*
|
|
63
|
-
* @param src - The source object.
|
|
64
|
-
* @param dest - The destination object.
|
|
65
|
-
* @param [config] - config for the Storage operation.
|
|
66
|
-
* @return A promise resolves to the copied object's key.
|
|
67
|
-
*/
|
|
68
|
-
copy<T extends Record<string, any>>(src: StorageCopySource, dest: StorageCopyDestination, config?: StorageCopyConfig<T>): StorageCopyOutput<T>;
|
|
69
|
-
/**
|
|
70
|
-
* Get a presigned URL of the file or the object data when download:true
|
|
71
|
-
*
|
|
72
|
-
* @param key - key of the object
|
|
73
|
-
* @param [config] - config for the Storage operation.
|
|
74
|
-
* @return - A promise resolves to either a presigned url or the object
|
|
75
|
-
*/
|
|
76
|
-
get<T extends Record<string, any> & {
|
|
77
|
-
download?: boolean;
|
|
78
|
-
}>(key: string, config?: StorageGetConfig<T>): StorageGetOutput<T>;
|
|
79
|
-
isCancelError(error: any): boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Put a file in storage bucket specified to configure method
|
|
82
|
-
* @param key - key of the object
|
|
83
|
-
* @param object - File to be put in bucket
|
|
84
|
-
* @param [config] - { level : private|protected|public, contentType: MIME Types,
|
|
85
|
-
* progressCallback: function }
|
|
86
|
-
* @return - promise resolves to object on success
|
|
87
|
-
*/
|
|
88
|
-
put<T extends Record<string, any>>(key: string, object: any, config?: StoragePutConfig<T>): StoragePutOutput<T>;
|
|
89
|
-
/**
|
|
90
|
-
* Remove the object for specified key
|
|
91
|
-
* @param key - key of the object
|
|
92
|
-
* @param [config] - { level : private|protected|public }
|
|
93
|
-
* @return - Promise resolves upon successful removal of the object
|
|
94
|
-
*/
|
|
95
|
-
remove<T extends Record<string, any>>(key: string, config?: StorageRemoveConfig<T>): StorageRemoveOutput<T>;
|
|
96
|
-
/**
|
|
97
|
-
* List bucket objects relative to the level and prefix specified
|
|
98
|
-
* @param path - the path that contains objects
|
|
99
|
-
* @param [config] - { level : private|protected|public, maxKeys: NUMBER }
|
|
100
|
-
* @return - Promise resolves to list of keys for all objects in path
|
|
101
|
-
*/
|
|
102
|
-
list<T extends Record<string, any>>(key: string, config?: StorageListConfig<T>): StorageListOutput<T>;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* @deprecated use named import
|
|
106
|
-
*/
|
|
107
|
-
export default Storage;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ICredentials } from '@aws-amplify/core';
|
|
3
|
-
import { StorageAccessLevel, CustomPrefix } from '../types';
|
|
4
|
-
import { InitializeMiddleware, InitializeHandlerOptions, FinalizeRequestHandlerOptions, FinalizeRequestMiddleware } from '@aws-sdk/types';
|
|
5
|
-
import { S3ClientConfig, S3Client } from '@aws-sdk/client-s3';
|
|
6
|
-
import { CancelTokenSource } from 'axios';
|
|
7
|
-
import * as events from 'events';
|
|
8
|
-
export declare const getPrefix: (config: {
|
|
9
|
-
credentials: ICredentials;
|
|
10
|
-
level?: StorageAccessLevel;
|
|
11
|
-
customPrefix?: CustomPrefix;
|
|
12
|
-
identityId?: string;
|
|
13
|
-
}) => string;
|
|
14
|
-
export declare const createPrefixMiddleware: (opt: Record<string, any>, key: string) => InitializeMiddleware<any, any>;
|
|
15
|
-
export declare const autoAdjustClockskewMiddleware: (config: S3ClientConfig) => FinalizeRequestMiddleware<any, any>;
|
|
16
|
-
export declare const autoAdjustClockskewMiddlewareOptions: FinalizeRequestHandlerOptions;
|
|
17
|
-
export declare const prefixMiddlewareOptions: InitializeHandlerOptions;
|
|
18
|
-
export declare const credentialsProvider: () => Promise<{
|
|
19
|
-
accessKeyId: any;
|
|
20
|
-
sessionToken: any;
|
|
21
|
-
secretAccessKey: any;
|
|
22
|
-
identityId: any;
|
|
23
|
-
authenticated: any;
|
|
24
|
-
} | {
|
|
25
|
-
accessKeyId: string;
|
|
26
|
-
secretAccessKey: string;
|
|
27
|
-
}>;
|
|
28
|
-
export declare const createS3Client: (config: {
|
|
29
|
-
region?: string;
|
|
30
|
-
cancelTokenSource?: CancelTokenSource;
|
|
31
|
-
dangerouslyConnectToHttpEndpointForTesting?: boolean;
|
|
32
|
-
useAccelerateEndpoint?: boolean;
|
|
33
|
-
}, emitter?: events.EventEmitter) => S3Client;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare enum StorageErrorStrings {
|
|
2
|
-
NO_CREDENTIALS = "No credentials",
|
|
3
|
-
NO_SRC_KEY = "source param should be an object with the property \"key\" with value of type string",
|
|
4
|
-
NO_DEST_KEY = "destination param should be an object with the property \"key\" with value of type string",
|
|
5
|
-
INVALID_BLOB = "Object must be an instance of Blob"
|
|
6
|
-
}
|
|
7
|
-
export declare enum AWSS3ProviderMultipartCopierErrors {
|
|
8
|
-
CLEANUP_FAILED = "Multipart copy clean up failed",
|
|
9
|
-
NO_OBJECT_FOUND = "Object does not exist",
|
|
10
|
-
INVALID_QUEUESIZE = "Queue size must be a positive number",
|
|
11
|
-
NO_COPYSOURCE = "You must specify a copy source",
|
|
12
|
-
MAX_NUM_PARTS_EXCEEDED = "Only a maximum of 10000 parts are allowed"
|
|
13
|
-
}
|
|
14
|
-
export declare enum AWSS3ProviderUploadErrorStrings {
|
|
15
|
-
UPLOAD_PAUSED_MESSAGE = "paused"
|
|
16
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const byteLength: (x: unknown) => number;
|
|
2
|
-
export declare const dispatchStorageEvent: (track: boolean, event: string, attrs: any, metrics: any, message: string) => void;
|
|
3
|
-
export declare const isFile: (x: unknown) => x is File;
|
|
4
|
-
export declare const isBlob: (x: unknown) => x is Blob;
|
package/lib/index.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { PutObjectCommandInput } from '@aws-sdk/client-s3';
|
|
2
|
-
import { StorageOptions, StorageProvider, S3ProviderGetConfig, S3ProviderGetOuput, S3ProviderPutConfig, S3ProviderRemoveConfig, S3ProviderListOutput, S3ProviderListConfig, S3ProviderCopyConfig, S3ProviderCopyOutput, S3CopySource, S3CopyDestination, S3ProviderRemoveOutput, S3ProviderPutOutput } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Provide storage methods to use AWS S3
|
|
5
|
-
*/
|
|
6
|
-
export declare class AWSS3Provider implements StorageProvider {
|
|
7
|
-
static readonly CATEGORY = "Storage";
|
|
8
|
-
static readonly PROVIDER_NAME = "AWSS3";
|
|
9
|
-
private _config;
|
|
10
|
-
private _storage;
|
|
11
|
-
/**
|
|
12
|
-
* Initialize Storage with AWS configurations
|
|
13
|
-
* @param {Object} config - Configuration object for storage
|
|
14
|
-
*/
|
|
15
|
-
constructor(config?: StorageOptions);
|
|
16
|
-
/**
|
|
17
|
-
* get the category of the plugin
|
|
18
|
-
*/
|
|
19
|
-
getCategory(): string;
|
|
20
|
-
/**
|
|
21
|
-
* get provider name of the plugin
|
|
22
|
-
*/
|
|
23
|
-
getProviderName(): 'AWSS3';
|
|
24
|
-
/**
|
|
25
|
-
* Configure Storage part with aws configuration
|
|
26
|
-
* @param {Object} config - Configuration of the Storage
|
|
27
|
-
* @return {Object} - Current configuration
|
|
28
|
-
*/
|
|
29
|
-
configure(config?: any): object;
|
|
30
|
-
private startResumableUpload;
|
|
31
|
-
/**
|
|
32
|
-
* Copy an object from a source object to a new object within the same bucket. Can optionally copy files across
|
|
33
|
-
* different level or identityId (if source object's level is 'protected').
|
|
34
|
-
*
|
|
35
|
-
* @async
|
|
36
|
-
* @param {S3CopySource} src - Key and optionally access level and identityId of the source object.
|
|
37
|
-
* @param {S3CopyDestination} dest - Key and optionally access level of the destination object.
|
|
38
|
-
* @param {S3ProviderCopyConfig} [config] - Optional configuration for s3 commands.
|
|
39
|
-
* @return {Promise<S3ProviderCopyOutput>} The key of the copied object.
|
|
40
|
-
*/
|
|
41
|
-
copy(src: S3CopySource, dest: S3CopyDestination, config?: S3ProviderCopyConfig): Promise<S3ProviderCopyOutput>;
|
|
42
|
-
/**
|
|
43
|
-
* Get a presigned URL of the file or the object data when download:true
|
|
44
|
-
*
|
|
45
|
-
* @param {string} key - key of the object
|
|
46
|
-
* @param {S3ProviderGetConfig} [config] - Optional configuration for the underlying S3 command
|
|
47
|
-
* @return {Promise<string | GetObjectCommandOutput>} - A promise resolves to Amazon S3 presigned URL or the
|
|
48
|
-
* GetObjectCommandOutput if download is set to true on success
|
|
49
|
-
*/
|
|
50
|
-
get<T extends S3ProviderGetConfig & StorageOptions>(key: string, config?: T): Promise<S3ProviderGetOuput<T>>;
|
|
51
|
-
/**
|
|
52
|
-
* Put a file in S3 bucket specified to configure method
|
|
53
|
-
* @param key - key of the object
|
|
54
|
-
* @param object - File to be put in Amazon S3 bucket
|
|
55
|
-
* @param [config] - Optional configuration for the underlying S3 command
|
|
56
|
-
* @return an instance of AWSS3UploadTask or a promise that resolves to an object with the new object's key on
|
|
57
|
-
* success.
|
|
58
|
-
*/
|
|
59
|
-
put<T extends S3ProviderPutConfig>(key: string, object: PutObjectCommandInput['Body'], config?: T): S3ProviderPutOutput<T>;
|
|
60
|
-
/**
|
|
61
|
-
* Remove the object for specified key
|
|
62
|
-
* @param {string} key - key of the object
|
|
63
|
-
* @param {S3ProviderRemoveConfig} [config] - Optional configuration for the underlying S3 command
|
|
64
|
-
* @return {Promise<S3ProviderRemoveOutput>} - Promise resolves upon successful removal of the object
|
|
65
|
-
*/
|
|
66
|
-
remove(key: string, config?: S3ProviderRemoveConfig): Promise<S3ProviderRemoveOutput>;
|
|
67
|
-
private _list;
|
|
68
|
-
/**
|
|
69
|
-
* List bucket objects relative to the level and prefix specified
|
|
70
|
-
* @param {string} path - the path that contains objects
|
|
71
|
-
* @param {S3ProviderListConfig} [config] - Optional configuration for the underlying S3 command
|
|
72
|
-
* @return {Promise<S3ProviderListOutput>} - Promise resolves to list of keys, eTags, lastModified and file size for
|
|
73
|
-
* all objects in path
|
|
74
|
-
*/
|
|
75
|
-
list(path: string, config?: S3ProviderListConfig): Promise<S3ProviderListOutput>;
|
|
76
|
-
private _ensureCredentials;
|
|
77
|
-
private _isWithCredentials;
|
|
78
|
-
private _prefix;
|
|
79
|
-
/**
|
|
80
|
-
* Creates an S3 client with new V3 aws sdk
|
|
81
|
-
*/
|
|
82
|
-
private _createNewS3Client;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* @deprecated use named import
|
|
86
|
-
*/
|
|
87
|
-
export default AWSS3Provider;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { PutObjectRequest, S3Client } from '@aws-sdk/client-s3';
|
|
3
|
-
import * as events from 'events';
|
|
4
|
-
export declare interface Part {
|
|
5
|
-
bodyPart: any;
|
|
6
|
-
partNumber: number;
|
|
7
|
-
emitter: events.EventEmitter;
|
|
8
|
-
etag?: string;
|
|
9
|
-
_lastUploadedBytes: number;
|
|
10
|
-
}
|
|
11
|
-
export declare class AWSS3ProviderManagedUpload {
|
|
12
|
-
protected minPartSize: number;
|
|
13
|
-
private queueSize;
|
|
14
|
-
private body;
|
|
15
|
-
private params;
|
|
16
|
-
private opts;
|
|
17
|
-
private completedParts;
|
|
18
|
-
private s3client;
|
|
19
|
-
private uploadId;
|
|
20
|
-
private bytesUploaded;
|
|
21
|
-
private totalBytesToUpload;
|
|
22
|
-
private emitter;
|
|
23
|
-
constructor(params: PutObjectRequest, opts: any, emitter: events.EventEmitter);
|
|
24
|
-
upload(): Promise<string | import("@aws-sdk/client-s3/types/").PutObjectCommandOutput>;
|
|
25
|
-
private createParts;
|
|
26
|
-
private createMultiPartUpload;
|
|
27
|
-
/**
|
|
28
|
-
* @private Not to be extended outside of tests
|
|
29
|
-
* @VisibleFotTesting
|
|
30
|
-
*/
|
|
31
|
-
protected uploadParts(uploadId: string, parts: Part[]): Promise<void>;
|
|
32
|
-
private finishMultiPartUpload;
|
|
33
|
-
private cleanup;
|
|
34
|
-
private removeEventListener;
|
|
35
|
-
private setupEventListener;
|
|
36
|
-
private progressChanged;
|
|
37
|
-
private byteLength;
|
|
38
|
-
private validateAndSanitizeBody;
|
|
39
|
-
private isGenericObject;
|
|
40
|
-
protected _createNewS3Client(config: any, emitter?: events.EventEmitter): S3Client;
|
|
41
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { UploadPartCommandInput, S3Client, PutObjectCommandInput } from '@aws-sdk/client-s3';
|
|
3
|
-
import * as events from 'events';
|
|
4
|
-
import { Canceler } from 'axios';
|
|
5
|
-
import { UploadTask } from '../types/Provider';
|
|
6
|
-
import { StorageAccessLevel } from '..';
|
|
7
|
-
export declare enum AWSS3UploadTaskState {
|
|
8
|
-
INIT = 0,
|
|
9
|
-
IN_PROGRESS = 1,
|
|
10
|
-
PAUSED = 2,
|
|
11
|
-
CANCELLED = 3,
|
|
12
|
-
COMPLETED = 4
|
|
13
|
-
}
|
|
14
|
-
export declare enum TaskEvents {
|
|
15
|
-
CANCEL = "cancel",
|
|
16
|
-
UPLOAD_COMPLETE = "uploadComplete",
|
|
17
|
-
UPLOAD_PROGRESS = "uploadPartProgress",
|
|
18
|
-
ERROR = "error"
|
|
19
|
-
}
|
|
20
|
-
export interface AWSS3UploadTaskParams {
|
|
21
|
-
s3Client: S3Client;
|
|
22
|
-
file: Blob;
|
|
23
|
-
storage: Storage;
|
|
24
|
-
level: StorageAccessLevel;
|
|
25
|
-
params: PutObjectCommandInput;
|
|
26
|
-
prefixPromise: Promise<string>;
|
|
27
|
-
emitter?: events.EventEmitter;
|
|
28
|
-
}
|
|
29
|
-
export interface InProgressRequest {
|
|
30
|
-
uploadPartInput: UploadPartCommandInput;
|
|
31
|
-
s3Request: Promise<any>;
|
|
32
|
-
cancel: Canceler;
|
|
33
|
-
}
|
|
34
|
-
export interface UploadTaskCompleteEvent {
|
|
35
|
-
key: string;
|
|
36
|
-
}
|
|
37
|
-
export interface UploadTaskProgressEvent {
|
|
38
|
-
/**
|
|
39
|
-
* bytes that has been sent to S3 so far
|
|
40
|
-
*/
|
|
41
|
-
loaded: number;
|
|
42
|
-
/**
|
|
43
|
-
* total bytes that needs to be sent to S3
|
|
44
|
-
*/
|
|
45
|
-
total: number;
|
|
46
|
-
}
|
|
47
|
-
export interface FileMetadata {
|
|
48
|
-
bucket: string;
|
|
49
|
-
fileName: string;
|
|
50
|
-
key: string;
|
|
51
|
-
lastTouched: number;
|
|
52
|
-
uploadId: string;
|
|
53
|
-
}
|
|
54
|
-
export declare class AWSS3UploadTask implements UploadTask {
|
|
55
|
-
private readonly emitter;
|
|
56
|
-
private readonly file;
|
|
57
|
-
private readonly partSize;
|
|
58
|
-
private readonly queueSize;
|
|
59
|
-
private readonly s3client;
|
|
60
|
-
private readonly storage;
|
|
61
|
-
private readonly storageSync;
|
|
62
|
-
private readonly fileId;
|
|
63
|
-
private readonly params;
|
|
64
|
-
private readonly prefixPromise;
|
|
65
|
-
private inProgress;
|
|
66
|
-
private completedParts;
|
|
67
|
-
private queued;
|
|
68
|
-
private bytesUploaded;
|
|
69
|
-
private totalBytes;
|
|
70
|
-
private uploadId;
|
|
71
|
-
state: AWSS3UploadTaskState;
|
|
72
|
-
constructor({ s3Client, file, emitter, storage, params, level, prefixPromise, }: AWSS3UploadTaskParams);
|
|
73
|
-
get percent(): number;
|
|
74
|
-
get isInProgress(): boolean;
|
|
75
|
-
private _listSingleFile;
|
|
76
|
-
private _getFileId;
|
|
77
|
-
private _findCachedUploadParts;
|
|
78
|
-
private _emitEvent;
|
|
79
|
-
private _validateParams;
|
|
80
|
-
private _listCachedUploadTasks;
|
|
81
|
-
private _cache;
|
|
82
|
-
private _isCached;
|
|
83
|
-
private _removeFromCache;
|
|
84
|
-
private _onPartUploadCompletion;
|
|
85
|
-
private _completeUpload;
|
|
86
|
-
private _makeUploadPartRequest;
|
|
87
|
-
private _startNextPart;
|
|
88
|
-
/**
|
|
89
|
-
* Verify on S3 side that the file size matches the one on the client side.
|
|
90
|
-
*
|
|
91
|
-
* @async
|
|
92
|
-
* @throws throws an error if the file size does not match between local copy of the file and the file on s3.
|
|
93
|
-
*/
|
|
94
|
-
private _verifyFileSize;
|
|
95
|
-
private _isDone;
|
|
96
|
-
private _createParts;
|
|
97
|
-
private _initCachedUploadParts;
|
|
98
|
-
private _initMultipartUpload;
|
|
99
|
-
private _initializeUploadTask;
|
|
100
|
-
resume(): void;
|
|
101
|
-
private _startUpload;
|
|
102
|
-
_cancel(): Promise<boolean>;
|
|
103
|
-
/**
|
|
104
|
-
* pause this particular upload task
|
|
105
|
-
**/
|
|
106
|
-
pause(): void;
|
|
107
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { HttpHandlerOptions } from '@aws-sdk/types';
|
|
3
|
-
import { HttpHandler, HttpRequest, HttpResponse } from '@aws-sdk/protocol-http';
|
|
4
|
-
import { CancelTokenSource, AxiosRequestHeaders, AxiosRequestTransformer } from 'axios';
|
|
5
|
-
import { FetchHttpHandlerOptions } from '@aws-sdk/fetch-http-handler';
|
|
6
|
-
import * as events from 'events';
|
|
7
|
-
/**
|
|
8
|
-
Extending the axios interface here to make headers required, (previously,
|
|
9
|
-
they were not required on the type we were using, but our implementation
|
|
10
|
-
does not currently account for missing headers. This worked previously,
|
|
11
|
-
because the previous `headers` type was `any`.
|
|
12
|
-
*/
|
|
13
|
-
interface AxiosTransformer extends Partial<AxiosRequestTransformer> {
|
|
14
|
-
(data: any, headers: AxiosRequestHeaders): any;
|
|
15
|
-
}
|
|
16
|
-
export declare const SEND_UPLOAD_PROGRESS_EVENT = "sendUploadProgress";
|
|
17
|
-
export declare const SEND_DOWNLOAD_PROGRESS_EVENT = "sendDownloadProgress";
|
|
18
|
-
export declare type ErrorWithResponse = {
|
|
19
|
-
response: {
|
|
20
|
-
status: number;
|
|
21
|
-
} & {
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export declare const reactNativeRequestTransformer: AxiosTransformer[];
|
|
26
|
-
export declare type AxiosHttpHandlerOptions = HttpHandlerOptions & {
|
|
27
|
-
cancelTokenSource?: CancelTokenSource;
|
|
28
|
-
emitter?: events.EventEmitter;
|
|
29
|
-
};
|
|
30
|
-
export declare class AxiosHttpHandler implements HttpHandler {
|
|
31
|
-
private readonly httpOptions;
|
|
32
|
-
private readonly emitter?;
|
|
33
|
-
private readonly cancelTokenSource?;
|
|
34
|
-
constructor(httpOptions?: FetchHttpHandlerOptions, emitter?: events.EventEmitter, cancelTokenSource?: CancelTokenSource);
|
|
35
|
-
destroy(): void;
|
|
36
|
-
handle(request: HttpRequest, options: AxiosHttpHandlerOptions): Promise<{
|
|
37
|
-
response: HttpResponse;
|
|
38
|
-
}>;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
package/lib/providers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AWSS3Provider } from './AWSS3Provider';
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { GetObjectRequest, GetObjectCommandOutput, PutObjectRequest, CopyObjectRequest, _Object, DeleteObjectCommandOutput } from '@aws-sdk/client-s3';
|
|
2
|
-
import { StorageOptions, StorageAccessLevel } from './Storage';
|
|
3
|
-
import { UploadTaskCompleteEvent, UploadTaskProgressEvent } from '../providers/AWSS3UploadTask';
|
|
4
|
-
import { UploadTask } from './Provider';
|
|
5
|
-
import { ICredentials } from '@aws-amplify/core';
|
|
6
|
-
declare type ListObjectsCommandOutputContent = _Object;
|
|
7
|
-
export interface FileMetadata {
|
|
8
|
-
bucket: string;
|
|
9
|
-
fileName: string;
|
|
10
|
-
key: string;
|
|
11
|
-
lastTouched: number;
|
|
12
|
-
uploadId: string;
|
|
13
|
-
}
|
|
14
|
-
export declare type CommonStorageOptions = Omit<StorageOptions, 'credentials' | 'region' | 'bucket' | 'dangerouslyConnectToHttpEndpointForTesting'>;
|
|
15
|
-
export declare type S3ProviderGetConfig = CommonStorageOptions & {
|
|
16
|
-
download?: boolean;
|
|
17
|
-
track?: boolean;
|
|
18
|
-
expires?: number;
|
|
19
|
-
provider?: 'AWSS3';
|
|
20
|
-
identityId?: string;
|
|
21
|
-
progressCallback?: (progress: any) => any;
|
|
22
|
-
cacheControl?: GetObjectRequest['ResponseCacheControl'];
|
|
23
|
-
contentDisposition?: GetObjectRequest['ResponseContentDisposition'];
|
|
24
|
-
contentEncoding?: GetObjectRequest['ResponseContentEncoding'];
|
|
25
|
-
contentLanguage?: GetObjectRequest['ResponseContentLanguage'];
|
|
26
|
-
contentType?: GetObjectRequest['ResponseContentType'];
|
|
27
|
-
SSECustomerAlgorithm?: GetObjectRequest['SSECustomerAlgorithm'];
|
|
28
|
-
SSECustomerKey?: GetObjectRequest['SSECustomerKey'];
|
|
29
|
-
SSECustomerKeyMD5?: GetObjectRequest['SSECustomerKeyMD5'];
|
|
30
|
-
};
|
|
31
|
-
export declare type S3ProviderGetOuput<T> = T extends {
|
|
32
|
-
download: true;
|
|
33
|
-
} ? GetObjectCommandOutput : string;
|
|
34
|
-
declare type _S3ProviderPutConfig = {
|
|
35
|
-
progressCallback?: (progress: any) => any;
|
|
36
|
-
provider?: 'AWSS3';
|
|
37
|
-
track?: boolean;
|
|
38
|
-
serverSideEncryption?: PutObjectRequest['ServerSideEncryption'];
|
|
39
|
-
SSECustomerAlgorithm?: PutObjectRequest['SSECustomerAlgorithm'];
|
|
40
|
-
SSECustomerKey?: PutObjectRequest['SSECustomerKey'];
|
|
41
|
-
SSECustomerKeyMD5?: PutObjectRequest['SSECustomerKeyMD5'];
|
|
42
|
-
SSEKMSKeyId?: PutObjectRequest['SSEKMSKeyId'];
|
|
43
|
-
acl?: PutObjectRequest['ACL'];
|
|
44
|
-
bucket?: PutObjectRequest['Bucket'];
|
|
45
|
-
cacheControl?: PutObjectRequest['CacheControl'];
|
|
46
|
-
contentDisposition?: PutObjectRequest['ContentDisposition'];
|
|
47
|
-
contentEncoding?: PutObjectRequest['ContentEncoding'];
|
|
48
|
-
contentType?: PutObjectRequest['ContentType'];
|
|
49
|
-
expires?: PutObjectRequest['Expires'];
|
|
50
|
-
metadata?: PutObjectRequest['Metadata'];
|
|
51
|
-
tagging?: PutObjectRequest['Tagging'];
|
|
52
|
-
useAccelerateEndpoint?: boolean;
|
|
53
|
-
resumable?: boolean;
|
|
54
|
-
};
|
|
55
|
-
export declare type ResumableUploadConfig = {
|
|
56
|
-
resumable: true;
|
|
57
|
-
progressCallback?: (progress: UploadTaskProgressEvent) => any;
|
|
58
|
-
completeCallback?: (event: UploadTaskCompleteEvent) => any;
|
|
59
|
-
errorCallback?: (err: any) => any;
|
|
60
|
-
};
|
|
61
|
-
export declare type S3ProviderPutConfig = CommonStorageOptions & (_S3ProviderPutConfig | (_S3ProviderPutConfig & ResumableUploadConfig));
|
|
62
|
-
export declare type S3ProviderRemoveConfig = CommonStorageOptions & {
|
|
63
|
-
bucket?: string;
|
|
64
|
-
provider?: 'AWSS3';
|
|
65
|
-
};
|
|
66
|
-
export declare type S3ProviderListOutputWithToken = {
|
|
67
|
-
contents: S3ProviderListOutputItem[];
|
|
68
|
-
nextToken: string;
|
|
69
|
-
};
|
|
70
|
-
export declare type S3ProviderRemoveOutput = DeleteObjectCommandOutput;
|
|
71
|
-
export declare type S3ProviderListConfig = CommonStorageOptions & {
|
|
72
|
-
bucket?: string;
|
|
73
|
-
maxKeys?: number | 'ALL';
|
|
74
|
-
provider?: 'AWSS3';
|
|
75
|
-
identityId?: string;
|
|
76
|
-
};
|
|
77
|
-
export declare type S3ClientOptions = StorageOptions & {
|
|
78
|
-
credentials: ICredentials;
|
|
79
|
-
} & S3ProviderListConfig;
|
|
80
|
-
export interface S3ProviderListOutputItem {
|
|
81
|
-
key: ListObjectsCommandOutputContent['Key'];
|
|
82
|
-
eTag: ListObjectsCommandOutputContent['ETag'];
|
|
83
|
-
lastModified: ListObjectsCommandOutputContent['LastModified'];
|
|
84
|
-
size: ListObjectsCommandOutputContent['Size'];
|
|
85
|
-
}
|
|
86
|
-
export declare type S3ProviderListOutput = S3ProviderListOutputItem[];
|
|
87
|
-
export interface S3CopyTarget {
|
|
88
|
-
key: string;
|
|
89
|
-
level?: StorageAccessLevel;
|
|
90
|
-
identityId?: string;
|
|
91
|
-
}
|
|
92
|
-
export declare type S3CopySource = S3CopyTarget;
|
|
93
|
-
export declare type S3CopyDestination = Omit<S3CopyTarget, 'identityId'>;
|
|
94
|
-
export declare type S3ProviderCopyConfig = Omit<CommonStorageOptions, 'level'> & {
|
|
95
|
-
provider?: 'AWSS3';
|
|
96
|
-
bucket?: CopyObjectRequest['Bucket'];
|
|
97
|
-
cacheControl?: CopyObjectRequest['CacheControl'];
|
|
98
|
-
contentDisposition?: CopyObjectRequest['ContentDisposition'];
|
|
99
|
-
contentLanguage?: CopyObjectRequest['ContentLanguage'];
|
|
100
|
-
contentType?: CopyObjectRequest['ContentType'];
|
|
101
|
-
expires?: CopyObjectRequest['Expires'];
|
|
102
|
-
tagging?: CopyObjectRequest['Tagging'];
|
|
103
|
-
acl?: CopyObjectRequest['ACL'];
|
|
104
|
-
metadata?: CopyObjectRequest['Metadata'];
|
|
105
|
-
serverSideEncryption?: CopyObjectRequest['ServerSideEncryption'];
|
|
106
|
-
SSECustomerAlgorithm?: CopyObjectRequest['SSECustomerAlgorithm'];
|
|
107
|
-
SSECustomerKey?: CopyObjectRequest['SSECustomerKey'];
|
|
108
|
-
SSECustomerKeyMD5?: CopyObjectRequest['SSECustomerKeyMD5'];
|
|
109
|
-
SSEKMSKeyId?: CopyObjectRequest['SSEKMSKeyId'];
|
|
110
|
-
};
|
|
111
|
-
export declare type S3ProviderCopyOutput = {
|
|
112
|
-
key: string;
|
|
113
|
-
};
|
|
114
|
-
export declare type PutResult = {
|
|
115
|
-
key: string;
|
|
116
|
-
};
|
|
117
|
-
export declare type S3ProviderPutOutput<T> = T extends {
|
|
118
|
-
resumable: true;
|
|
119
|
-
} ? UploadTask : Promise<PutResult>;
|
|
120
|
-
export {};
|
package/lib/types/Provider.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { StorageCopySource, StorageCopyDestination } from './Storage';
|
|
2
|
-
export interface StorageProvider {
|
|
3
|
-
cancel?(request: Promise<any>): void;
|
|
4
|
-
copy?(src: StorageCopySource, dest: StorageCopyDestination, config?: any): Promise<any>;
|
|
5
|
-
configure(config: object): object;
|
|
6
|
-
get(key: string, options?: any): Promise<string | Object>;
|
|
7
|
-
put(key: string, object: any, options?: any): Promise<Object> | UploadTask;
|
|
8
|
-
remove(key: string, options?: any): Promise<any>;
|
|
9
|
-
list(path: any, options?: any): Promise<any>;
|
|
10
|
-
getCategory(): string;
|
|
11
|
-
getProviderName(): string;
|
|
12
|
-
}
|
|
13
|
-
export interface UploadTask {
|
|
14
|
-
resume(): any;
|
|
15
|
-
pause(): any;
|
|
16
|
-
percent: number;
|
|
17
|
-
isInProgress: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface StorageProviderWithCopy extends StorageProvider {
|
|
20
|
-
copy(src: StorageCopySource, dest: StorageCopyDestination, config?: any): Promise<any>;
|
|
21
|
-
}
|
|
22
|
-
export declare type StorageProviderApi = 'copy' | 'get' | 'put' | 'remove' | 'list';
|
package/lib/types/Storage.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage instance options
|
|
3
|
-
*/
|
|
4
|
-
import { ICredentials } from '@aws-amplify/core';
|
|
5
|
-
import { StorageProvider, StorageProviderApi, AWSS3Provider, StorageProviderWithCopy, S3ProviderGetOuput, S3ProviderRemoveOutput, S3ProviderListOutput, S3ProviderCopyOutput, S3ProviderPutOutput } from '../';
|
|
6
|
-
declare type Tail<T extends any[]> = ((...t: T) => void) extends (h: any, ...r: infer R) => void ? R : never;
|
|
7
|
-
declare type Last<T extends any[]> = T[Exclude<keyof T, keyof Tail<T>>];
|
|
8
|
-
declare type LastParameter<F extends (...args: any) => any> = Last<Parameters<F>>;
|
|
9
|
-
export interface StorageOptions {
|
|
10
|
-
credentials?: ICredentials;
|
|
11
|
-
region?: string;
|
|
12
|
-
level?: StorageAccessLevel;
|
|
13
|
-
bucket?: string;
|
|
14
|
-
provider?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Custom mapping of your prefixes.
|
|
17
|
-
* For example, customPrefix: { public: 'myPublicPrefix' } will make public level operations access 'myPublicPrefix/'
|
|
18
|
-
* instead of the default 'public/'.
|
|
19
|
-
*/
|
|
20
|
-
customPrefix?: CustomPrefix;
|
|
21
|
-
/**
|
|
22
|
-
* if set to true, automatically sends Storage Events to Amazon Pinpoint
|
|
23
|
-
**/
|
|
24
|
-
track?: boolean;
|
|
25
|
-
dangerouslyConnectToHttpEndpointForTesting?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export declare type StorageAccessLevel = 'public' | 'protected' | 'private';
|
|
28
|
-
export declare type CustomPrefix = {
|
|
29
|
-
[key in StorageAccessLevel]?: string;
|
|
30
|
-
};
|
|
31
|
-
export declare type StorageCopyTarget = {
|
|
32
|
-
key: string;
|
|
33
|
-
level?: string;
|
|
34
|
-
identityId?: string;
|
|
35
|
-
};
|
|
36
|
-
export declare type StorageCopySource = StorageCopyTarget;
|
|
37
|
-
export declare type StorageCopyDestination = Omit<StorageCopyTarget, 'identityId'>;
|
|
38
|
-
/**
|
|
39
|
-
* If provider is AWSS3, provider doesn't have to be specified since it's the default, else it has to be passed into
|
|
40
|
-
* config.
|
|
41
|
-
*/
|
|
42
|
-
declare type StorageOperationConfig<T extends StorageProvider | StorageProviderWithCopy, U extends StorageProviderApi> = ReturnType<T['getProviderName']> extends 'AWSS3' ? LastParameter<AWSS3Provider[U]> : T extends StorageProviderWithCopy ? LastParameter<T[U]> & {
|
|
43
|
-
provider: ReturnType<T['getProviderName']>;
|
|
44
|
-
} : LastParameter<T[Exclude<U, 'copy'>]> & {
|
|
45
|
-
provider: ReturnType<T['getProviderName']>;
|
|
46
|
-
};
|
|
47
|
-
export declare type StorageGetConfig<T> = T extends StorageProvider ? StorageOperationConfig<T, 'get'> : StorageOperationConfigMap<StorageOperationConfig<AWSS3Provider, 'get'>, T>;
|
|
48
|
-
export declare type StoragePutConfig<T> = T extends StorageProvider ? StorageOperationConfig<T, 'put'> : StorageOperationConfigMap<StorageOperationConfig<AWSS3Provider, 'put'>, T>;
|
|
49
|
-
export declare type StorageRemoveConfig<T> = T extends StorageProvider ? StorageOperationConfig<T, 'remove'> : StorageOperationConfigMap<StorageOperationConfig<AWSS3Provider, 'remove'>, T>;
|
|
50
|
-
export declare type StorageListConfig<T> = T extends StorageProvider ? StorageOperationConfig<T, 'list'> : StorageOperationConfigMap<StorageOperationConfig<AWSS3Provider, 'list'>, T>;
|
|
51
|
-
export declare type StorageCopyConfig<T> = T extends StorageProviderWithCopy ? StorageOperationConfig<T, 'copy'> : StorageOperationConfigMap<StorageOperationConfig<AWSS3Provider, 'copy'>, T>;
|
|
52
|
-
/**
|
|
53
|
-
* Utility type for checking if the generic type is a provider or a Record that has the key 'provider'.
|
|
54
|
-
* If it's a provider, check if it's the S3 Provider, use the default type else use the generic's 'get' method
|
|
55
|
-
* return type.
|
|
56
|
-
* If it's a Record, check if provider is 'AWSS3', use the default type else use any.
|
|
57
|
-
*/
|
|
58
|
-
declare type PickProviderOutput<DefaultOutput, T, api extends StorageProviderApi> = T extends StorageProvider ? T['getProviderName'] extends 'AWSS3' ? DefaultOutput : T extends StorageProviderWithCopy ? ReturnType<T[api]> : ReturnType<T[Exclude<api, 'copy'>]> : T extends {
|
|
59
|
-
provider: string;
|
|
60
|
-
} ? T extends {
|
|
61
|
-
provider: 'AWSS3';
|
|
62
|
-
} ? DefaultOutput : Promise<any> : DefaultOutput;
|
|
63
|
-
export declare type StorageGetOutput<T extends StorageProvider | Record<string, any>> = PickProviderOutput<Promise<S3ProviderGetOuput<T>>, T, 'get'>;
|
|
64
|
-
export declare type StoragePutOutput<T> = PickProviderOutput<S3ProviderPutOutput<T>, T, 'put'>;
|
|
65
|
-
export declare type StorageRemoveOutput<T> = PickProviderOutput<Promise<S3ProviderRemoveOutput>, T, 'remove'>;
|
|
66
|
-
export declare type StorageListOutput<T> = PickProviderOutput<Promise<S3ProviderListOutput>, T, 'list'>;
|
|
67
|
-
export declare type StorageCopyOutput<T> = PickProviderOutput<Promise<S3ProviderCopyOutput>, T, 'copy'>;
|
|
68
|
-
/**
|
|
69
|
-
* Utility type to allow custom provider to use any config keys, if provider is set to AWSS3 then it should use
|
|
70
|
-
* AWSS3Provider's config.
|
|
71
|
-
*/
|
|
72
|
-
export declare type StorageOperationConfigMap<Default, T extends Record<string, any>> = T extends {
|
|
73
|
-
provider: string;
|
|
74
|
-
} ? T extends {
|
|
75
|
-
provider: 'AWSS3';
|
|
76
|
-
} ? Default : T & {
|
|
77
|
-
provider: string;
|
|
78
|
-
} : Default;
|
|
79
|
-
export {};
|
package/lib/types/index.d.ts
DELETED