@aws-amplify/storage 4.5.15-unstable.2 → 4.5.15
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 +16 -0
- package/build.js +5 -0
- package/dist/aws-amplify-storage.js +51312 -0
- package/dist/aws-amplify-storage.js.map +1 -0
- package/dist/aws-amplify-storage.min.js +26 -0
- package/dist/aws-amplify-storage.min.js.map +1 -0
- package/index.js +7 -0
- package/lib/Storage.js +69 -54
- package/lib/Storage.js.map +1 -1
- package/lib/common/S3ClientUtils.js +55 -9
- package/lib/common/S3ClientUtils.js.map +1 -1
- package/lib/index.js +58 -5
- package/lib/index.js.map +1 -1
- package/lib/providers/AWSS3Provider.js +149 -70
- package/lib/providers/AWSS3Provider.js.map +1 -1
- package/lib/providers/AWSS3ProviderManagedUpload.js +82 -19
- package/lib/providers/AWSS3ProviderManagedUpload.js.map +1 -1
- package/lib/providers/AWSS3UploadTask.js +87 -29
- package/lib/providers/AWSS3UploadTask.js.map +1 -1
- package/lib/providers/axios-http-handler.js +45 -6
- package/lib/providers/axios-http-handler.js.map +1 -1
- package/lib/types/Storage.js +12 -2
- package/lib/types/Storage.js.map +1 -1
- package/lib/types/index.js +12 -2
- package/lib/types/index.js.map +1 -1
- package/lib-esm/Storage.d.ts +4 -1
- package/lib-esm/Storage.js +61 -49
- package/lib-esm/Storage.js.map +1 -1
- package/lib-esm/common/S3ClientUtils.js +47 -1
- package/lib-esm/common/S3ClientUtils.js.map +1 -1
- package/lib-esm/index.d.ts +8 -3
- package/lib-esm/index.js +57 -5
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/providers/AWSS3Provider.d.ts +7 -3
- package/lib-esm/providers/AWSS3Provider.js +126 -54
- package/lib-esm/providers/AWSS3Provider.js.map +1 -1
- package/lib-esm/providers/AWSS3ProviderManagedUpload.js +59 -3
- package/lib-esm/providers/AWSS3ProviderManagedUpload.js.map +1 -1
- package/lib-esm/providers/AWSS3UploadTask.js +56 -1
- package/lib-esm/providers/AWSS3UploadTask.js.map +1 -1
- package/lib-esm/providers/axios-http-handler.js +39 -3
- package/lib-esm/providers/axios-http-handler.js.map +1 -1
- package/lib-esm/types/AWSS3Provider.d.ts +5 -6
- package/lib-esm/types/Storage.js +12 -2
- package/lib-esm/types/Storage.js.map +1 -1
- package/lib-esm/types/index.js +12 -2
- package/lib-esm/types/index.js.map +1 -1
- package/package.json +10 -14
- package/src/Storage.ts +33 -59
- package/src/index.ts +57 -5
- package/src/providers/AWSS3Provider.ts +50 -41
- package/src/providers/AWSS3ProviderManagedUpload.ts +12 -2
- package/src/providers/axios-http-handler.ts +12 -2
- package/src/types/AWSS3Provider.ts +6 -6
- package/src/types/Provider.ts +12 -2
- package/src/types/Storage.ts +12 -2
- package/src/types/index.ts +12 -2
- package/webpack.config.dev.js +6 -0
- package/lib/.tsbuildinfo +0 -3
- package/lib/Storage.d.ts +0 -104
- 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 -4
- package/lib/providers/AWSS3Provider.d.ts +0 -83
- 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 -121
- 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/lib-esm/.tsbuildinfo +0 -3
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
|
+
* the License. A copy of the License is located at
|
|
6
|
+
*
|
|
7
|
+
* http://aws.amazon.com/apache2.0/
|
|
8
|
+
*
|
|
9
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
* and limitations under the License.
|
|
12
|
+
*/
|
|
3
13
|
import {
|
|
4
14
|
ConsoleLogger as Logger,
|
|
5
15
|
Credentials,
|
|
16
|
+
Parser,
|
|
6
17
|
ICredentials,
|
|
7
18
|
StorageHelper,
|
|
8
19
|
Hub,
|
|
9
|
-
parseAWSExports,
|
|
10
20
|
} from '@aws-amplify/core';
|
|
11
21
|
import {
|
|
12
22
|
S3Client,
|
|
@@ -35,6 +45,7 @@ import {
|
|
|
35
45
|
S3ProviderGetOuput,
|
|
36
46
|
S3ProviderPutConfig,
|
|
37
47
|
S3ProviderRemoveConfig,
|
|
48
|
+
S3ProviderListOutput,
|
|
38
49
|
S3ProviderListConfig,
|
|
39
50
|
S3ProviderCopyConfig,
|
|
40
51
|
S3ProviderCopyOutput,
|
|
@@ -47,7 +58,6 @@ import {
|
|
|
47
58
|
ResumableUploadConfig,
|
|
48
59
|
UploadTask,
|
|
49
60
|
S3ClientOptions,
|
|
50
|
-
S3ProviderListOutput,
|
|
51
61
|
} from '../types';
|
|
52
62
|
import { StorageErrorStrings } from '../common/StorageErrorStrings';
|
|
53
63
|
import { dispatchStorageEvent } from '../common/StorageUtils';
|
|
@@ -59,6 +69,7 @@ import {
|
|
|
59
69
|
autoAdjustClockskewMiddlewareOptions,
|
|
60
70
|
createS3Client,
|
|
61
71
|
} from '../common/S3ClientUtils';
|
|
72
|
+
import { S3ProviderListOutputWithToken } from '.././types/AWSS3Provider';
|
|
62
73
|
import { AWSS3ProviderManagedUpload } from './AWSS3ProviderManagedUpload';
|
|
63
74
|
import { AWSS3UploadTask, TaskEvents } from './AWSS3UploadTask';
|
|
64
75
|
import { UPLOADS_STORAGE_KEY } from '../common/StorageConstants';
|
|
@@ -127,7 +138,7 @@ export class AWSS3Provider implements StorageProvider {
|
|
|
127
138
|
public configure(config?): object {
|
|
128
139
|
logger.debug('configure Storage', config);
|
|
129
140
|
if (!config) return this._config;
|
|
130
|
-
const amplifyConfig =
|
|
141
|
+
const amplifyConfig = Parser.parseMobilehubConfig(config);
|
|
131
142
|
this._config = Object.assign({}, this._config, amplifyConfig.Storage);
|
|
132
143
|
if (!this._config.bucket) {
|
|
133
144
|
logger.debug('Do not have bucket yet');
|
|
@@ -674,16 +685,16 @@ export class AWSS3Provider implements StorageProvider {
|
|
|
674
685
|
params: ListObjectsV2Request,
|
|
675
686
|
opt: S3ClientOptions,
|
|
676
687
|
prefix: string
|
|
677
|
-
): Promise<
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
|
|
688
|
+
): Promise<S3ProviderListOutputWithToken> {
|
|
689
|
+
const result: S3ProviderListOutputWithToken = {
|
|
690
|
+
contents: [],
|
|
691
|
+
nextToken: '',
|
|
681
692
|
};
|
|
682
693
|
const s3 = this._createNewS3Client(opt);
|
|
683
694
|
const listObjectsV2Command = new ListObjectsV2Command({ ...params });
|
|
684
695
|
const response = await s3.send(listObjectsV2Command);
|
|
685
696
|
if (response && response.Contents) {
|
|
686
|
-
|
|
697
|
+
result.contents = response.Contents.map(item => {
|
|
687
698
|
return {
|
|
688
699
|
key: item.Key.substr(prefix.length),
|
|
689
700
|
eTag: item.ETag,
|
|
@@ -691,18 +702,17 @@ export class AWSS3Provider implements StorageProvider {
|
|
|
691
702
|
size: item.Size,
|
|
692
703
|
};
|
|
693
704
|
});
|
|
694
|
-
|
|
695
|
-
list.hasNextToken = response.IsTruncated;
|
|
705
|
+
result.nextToken = response.NextContinuationToken;
|
|
696
706
|
}
|
|
697
|
-
return
|
|
707
|
+
return result;
|
|
698
708
|
}
|
|
699
709
|
|
|
700
710
|
/**
|
|
701
711
|
* List bucket objects relative to the level and prefix specified
|
|
702
712
|
* @param {string} path - the path that contains objects
|
|
703
713
|
* @param {S3ProviderListConfig} [config] - Optional configuration for the underlying S3 command
|
|
704
|
-
* @return {Promise<S3ProviderListOutput>} - Promise resolves to list of keys, eTags, lastModified
|
|
705
|
-
*
|
|
714
|
+
* @return {Promise<S3ProviderListOutput>} - Promise resolves to list of keys, eTags, lastModified and file size for
|
|
715
|
+
* all objects in path
|
|
706
716
|
*/
|
|
707
717
|
public async list(
|
|
708
718
|
path: string,
|
|
@@ -713,55 +723,49 @@ export class AWSS3Provider implements StorageProvider {
|
|
|
713
723
|
throw new Error(StorageErrorStrings.NO_CREDENTIALS);
|
|
714
724
|
}
|
|
715
725
|
const opt: S3ClientOptions = Object.assign({}, this._config, config);
|
|
716
|
-
const { bucket, track,
|
|
726
|
+
const { bucket, track, maxKeys } = opt;
|
|
717
727
|
const prefix = this._prefix(opt);
|
|
718
728
|
const final_path = prefix + path;
|
|
719
729
|
logger.debug('list ' + path + ' from ' + final_path);
|
|
720
730
|
try {
|
|
721
|
-
const list: S3ProviderListOutput =
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
};
|
|
725
|
-
const MAX_PAGE_SIZE = 1000;
|
|
726
|
-
let listResult: S3ProviderListOutput;
|
|
731
|
+
const list: S3ProviderListOutput = [];
|
|
732
|
+
let token: string;
|
|
733
|
+
let listResult: S3ProviderListOutputWithToken;
|
|
727
734
|
const params: ListObjectsV2Request = {
|
|
728
735
|
Bucket: bucket,
|
|
729
736
|
Prefix: final_path,
|
|
730
|
-
MaxKeys:
|
|
731
|
-
ContinuationToken: nextToken,
|
|
737
|
+
MaxKeys: 1000,
|
|
732
738
|
};
|
|
733
|
-
|
|
734
|
-
if (pageSize === 'ALL') {
|
|
739
|
+
if (maxKeys === 'ALL') {
|
|
735
740
|
do {
|
|
741
|
+
params.ContinuationToken = token;
|
|
742
|
+
params.MaxKeys = 1000;
|
|
736
743
|
listResult = await this._list(params, opt, prefix);
|
|
737
|
-
list.
|
|
738
|
-
if (listResult.nextToken)
|
|
739
|
-
params.ContinuationToken = listResult.nextToken;
|
|
744
|
+
list.push(...listResult.contents);
|
|
745
|
+
if (listResult.nextToken) token = listResult.nextToken;
|
|
740
746
|
} while (listResult.nextToken);
|
|
741
747
|
} else {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
typeof pageSize === 'number'
|
|
746
|
-
)
|
|
747
|
-
params.MaxKeys = pageSize;
|
|
748
|
-
else logger.warn(`pageSize should be from 0 - ${MAX_PAGE_SIZE}.`);
|
|
748
|
+
maxKeys < 1000 || typeof maxKeys === 'string'
|
|
749
|
+
? (params.MaxKeys = maxKeys)
|
|
750
|
+
: (params.MaxKeys = 1000);
|
|
749
751
|
listResult = await this._list(params, opt, prefix);
|
|
750
|
-
list.
|
|
751
|
-
|
|
752
|
-
|
|
752
|
+
list.push(...listResult.contents);
|
|
753
|
+
if (maxKeys > 1000)
|
|
754
|
+
logger.warn(
|
|
755
|
+
"maxkeys can be from 0 - 1000 or 'ALL'. To list all files you can set maxKeys to 'ALL'."
|
|
756
|
+
);
|
|
753
757
|
}
|
|
754
758
|
dispatchStorageEvent(
|
|
755
759
|
track,
|
|
756
760
|
'list',
|
|
757
761
|
{ method: 'list', result: 'success' },
|
|
758
762
|
null,
|
|
759
|
-
`${list.
|
|
763
|
+
`${list.length} items returned from list operation`
|
|
760
764
|
);
|
|
761
765
|
logger.debug('list', list);
|
|
762
766
|
return list;
|
|
763
767
|
} catch (error) {
|
|
764
|
-
logger.
|
|
768
|
+
logger.warn('list error', error);
|
|
765
769
|
dispatchStorageEvent(
|
|
766
770
|
track,
|
|
767
771
|
'list',
|
|
@@ -847,3 +851,8 @@ export class AWSS3Provider implements StorageProvider {
|
|
|
847
851
|
return s3client;
|
|
848
852
|
}
|
|
849
853
|
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* @deprecated use named import
|
|
857
|
+
*/
|
|
858
|
+
export default AWSS3Provider;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
|
+
* the License. A copy of the License is located at
|
|
6
|
+
*
|
|
7
|
+
* http://aws.amazon.com/apache2.0/
|
|
8
|
+
*
|
|
9
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
* and limitations under the License.
|
|
12
|
+
*/
|
|
3
13
|
|
|
4
14
|
import { ConsoleLogger as Logger } from '@aws-amplify/core';
|
|
5
15
|
import {
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
|
+
* the License. A copy of the License is located at
|
|
6
|
+
*
|
|
7
|
+
* http://aws.amazon.com/apache2.0/
|
|
8
|
+
*
|
|
9
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
* and limitations under the License.
|
|
12
|
+
*/
|
|
3
13
|
|
|
4
14
|
import { HttpHandlerOptions } from '@aws-sdk/types';
|
|
5
15
|
import { HttpHandler, HttpRequest, HttpResponse } from '@aws-sdk/protocol-http';
|
|
@@ -95,20 +95,18 @@ export type S3ProviderRemoveConfig = CommonStorageOptions & {
|
|
|
95
95
|
provider?: 'AWSS3';
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
export type
|
|
99
|
-
|
|
100
|
-
nextToken
|
|
101
|
-
hasNextToken: boolean;
|
|
98
|
+
export type S3ProviderListOutputWithToken = {
|
|
99
|
+
contents: S3ProviderListOutputItem[];
|
|
100
|
+
nextToken: string;
|
|
102
101
|
};
|
|
103
102
|
|
|
104
103
|
export type S3ProviderRemoveOutput = DeleteObjectCommandOutput;
|
|
105
104
|
|
|
106
105
|
export type S3ProviderListConfig = CommonStorageOptions & {
|
|
107
106
|
bucket?: string;
|
|
108
|
-
|
|
107
|
+
maxKeys?: number | 'ALL';
|
|
109
108
|
provider?: 'AWSS3';
|
|
110
109
|
identityId?: string;
|
|
111
|
-
nextToken?: string;
|
|
112
110
|
};
|
|
113
111
|
|
|
114
112
|
export type S3ClientOptions = StorageOptions & {
|
|
@@ -122,6 +120,8 @@ export interface S3ProviderListOutputItem {
|
|
|
122
120
|
size: ListObjectsCommandOutputContent['Size'];
|
|
123
121
|
}
|
|
124
122
|
|
|
123
|
+
export type S3ProviderListOutput = S3ProviderListOutputItem[];
|
|
124
|
+
|
|
125
125
|
export interface S3CopyTarget {
|
|
126
126
|
key: string;
|
|
127
127
|
level?: StorageAccessLevel;
|
package/src/types/Provider.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { StorageCopySource, StorageCopyDestination } from './Storage';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
|
+
* the License. A copy of the License is located at
|
|
7
|
+
*
|
|
8
|
+
* http://aws.amazon.com/apache2.0/
|
|
9
|
+
*
|
|
10
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
11
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
12
|
+
* and limitations under the License.
|
|
13
|
+
*/
|
|
4
14
|
export interface StorageProvider {
|
|
5
15
|
// you need to implement those methods
|
|
6
16
|
|
package/src/types/Storage.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
|
+
* the License. A copy of the License is located at
|
|
6
|
+
*
|
|
7
|
+
* http://aws.amazon.com/apache2.0/
|
|
8
|
+
*
|
|
9
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
* and limitations under the License.
|
|
12
|
+
*/
|
|
3
13
|
/**
|
|
4
14
|
* Storage instance options
|
|
5
15
|
*/
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
|
+
* the License. A copy of the License is located at
|
|
6
|
+
*
|
|
7
|
+
* http://aws.amazon.com/apache2.0/
|
|
8
|
+
*
|
|
9
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
* and limitations under the License.
|
|
12
|
+
*/
|
|
3
13
|
|
|
4
14
|
export * from './Storage';
|
|
5
15
|
export * from './Provider';
|
package/lib/.tsbuildinfo
DELETED
package/lib/Storage.d.ts
DELETED
|
@@ -1,104 +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
|
-
export declare const StorageInstance: 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,83 +0,0 @@
|
|
|
1
|
-
import { PutObjectCommandInput } from '@aws-sdk/client-s3';
|
|
2
|
-
import { StorageOptions, StorageProvider, S3ProviderGetConfig, S3ProviderGetOuput, S3ProviderPutConfig, S3ProviderRemoveConfig, S3ProviderListConfig, S3ProviderCopyConfig, S3ProviderCopyOutput, S3CopySource, S3CopyDestination, S3ProviderRemoveOutput, S3ProviderPutOutput, S3ProviderListOutput } 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
|
|
73
|
-
* and file size for 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
|
-
}
|
|
@@ -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
|
-
}
|