@aws-amplify/storage
Advanced tools
Comparing version 1.1.3-unstable.11 to 1.1.3-unstable.12
429
CHANGELOG.md
@@ -10,39 +10,20 @@ # Change Log | ||
## [1.1.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.1.0...@aws-amplify/storage@1.1.1) (2019-09-04) | ||
### Bug Fixes | ||
* **@aws-amplify/storage:** fix typo ([#3828](https://github.com/aws/aws-amplify/issues/3828)) ([b93af35](https://github.com/aws/aws-amplify/commit/b93af35)) | ||
- **@aws-amplify/storage:** fix typo ([#3828](https://github.com/aws/aws-amplify/issues/3828)) ([b93af35](https://github.com/aws/aws-amplify/commit/b93af35)) | ||
# [1.1.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.36...@aws-amplify/storage@1.1.0) (2019-08-05) | ||
### Features | ||
* Add support for local testing of api and storage ([#3806](https://github.com/aws/aws-amplify/issues/3806)) ([4390e8e](https://github.com/aws/aws-amplify/commit/4390e8e)) | ||
- Add support for local testing of api and storage ([#3806](https://github.com/aws/aws-amplify/issues/3806)) ([4390e8e](https://github.com/aws/aws-amplify/commit/4390e8e)) | ||
## [1.0.36](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.35...@aws-amplify/storage@1.0.36) (2019-08-01) | ||
### Bug Fixes | ||
* **@aws-amplify/storage:** removed not using variables ([#3768](https://github.com/aws/aws-amplify/issues/3768)) ([4164cf5](https://github.com/aws/aws-amplify/commit/4164cf5)) | ||
- **@aws-amplify/storage:** removed not using variables ([#3768](https://github.com/aws/aws-amplify/issues/3768)) ([4164cf5](https://github.com/aws/aws-amplify/commit/4164cf5)) | ||
## [1.0.35](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.34...@aws-amplify/storage@1.0.35) (2019-07-31) | ||
@@ -52,6 +33,2 @@ | ||
## [1.0.34](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.33...@aws-amplify/storage@1.0.34) (2019-07-30) | ||
@@ -61,6 +38,2 @@ | ||
## [1.0.33](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.31...@aws-amplify/storage@1.0.33) (2019-07-18) | ||
@@ -70,755 +43,561 @@ | ||
<a name="1.0.32-unstable.1"></a> | ||
<a name="1.0.32-unstable.1"></a> | ||
## [1.0.32-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.31...@aws-amplify/storage@1.0.32-unstable.1) (2019-07-12) | ||
### Bug Fixes | ||
* allow SSE to be passed in global configure of storage ([9ee76cc](https://github.com/aws/aws-amplify/commit/9ee76cc)) | ||
* allow SSE to be passed in global configure of storage ([8fb26c4](https://github.com/aws/aws-amplify/commit/8fb26c4)) | ||
- allow SSE to be passed in global configure of storage ([9ee76cc](https://github.com/aws/aws-amplify/commit/9ee76cc)) | ||
- allow SSE to be passed in global configure of storage ([8fb26c4](https://github.com/aws/aws-amplify/commit/8fb26c4)) | ||
<a name="1.0.31"></a> | ||
<a name="1.0.31"></a> | ||
## [1.0.31](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.31-unstable.2...@aws-amplify/storage@1.0.31) (2019-06-17) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.31-unstable.2"></a> | ||
## [1.0.31-unstable.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.31-unstable.1...@aws-amplify/storage@1.0.31-unstable.2) (2019-06-14) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.31-unstable.1"></a> | ||
## [1.0.31-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.30...@aws-amplify/storage@1.0.31-unstable.1) (2019-05-24) | ||
### Bug Fixes | ||
* **aws-amplify:** manual version bumps for lerna issue ([9ce5a72](https://github.com/aws/aws-amplify/commit/9ce5a72)) | ||
- **aws-amplify:** manual version bumps for lerna issue ([9ce5a72](https://github.com/aws/aws-amplify/commit/9ce5a72)) | ||
<a name="1.0.30"></a> | ||
<a name="1.0.30"></a> | ||
## [1.0.30](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.30-unstable.1...@aws-amplify/storage@1.0.30) (2019-05-14) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.30-unstable.1"></a> | ||
## [1.0.30-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.30-unstable.0...@aws-amplify/storage@1.0.30-unstable.1) (2019-05-13) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.30-unstable.0"></a> | ||
## [1.0.30-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.29...@aws-amplify/storage@1.0.30-unstable.0) (2019-05-10) | ||
### Bug Fixes | ||
* **@aws-amplify/storage:** The issue was when configuring Amplify or Storage more than once, e.g. `Amplify.configure(...)` or `Storage.configure(...)` the default level was set to `private`. The default level will always be `public` except when you configure it to something different like `Storage.configure({ level: 'protected' })` ([#3222](https://github.com/aws/aws-amplify/issues/3222)) ([8b46eb8](https://github.com/aws/aws-amplify/commit/8b46eb8)) | ||
- **@aws-amplify/storage:** The issue was when configuring Amplify or Storage more than once, e.g. `Amplify.configure(...)` or `Storage.configure(...)` the default level was set to `private`. The default level will always be `public` except when you configure it to something different like `Storage.configure({ level: 'protected' })` ([#3222](https://github.com/aws/aws-amplify/issues/3222)) ([8b46eb8](https://github.com/aws/aws-amplify/commit/8b46eb8)) | ||
<a name="1.0.29"></a> | ||
<a name="1.0.29"></a> | ||
## [1.0.29](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.29-unstable.3...@aws-amplify/storage@1.0.29) (2019-05-06) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.29-unstable.3"></a> | ||
## [1.0.29-unstable.3](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.29-unstable.2...@aws-amplify/storage@1.0.29-unstable.3) (2019-05-06) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.29-unstable.2"></a> | ||
## [1.0.29-unstable.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.29-unstable.1...@aws-amplify/storage@1.0.29-unstable.2) (2019-04-17) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.29-unstable.1"></a> | ||
## [1.0.29-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.29-unstable.0...@aws-amplify/storage@1.0.29-unstable.1) (2019-04-15) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.29-unstable.0"></a> | ||
## [1.0.29-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.28...@aws-amplify/storage@1.0.29-unstable.0) (2019-04-12) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.28"></a> | ||
## [1.0.28](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.28-unstable.1...@aws-amplify/storage@1.0.28) (2019-04-04) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.28-unstable.1"></a> | ||
## [1.0.28-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.28-unstable.0...@aws-amplify/storage@1.0.28-unstable.1) (2019-04-04) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.28-unstable.0"></a> | ||
## [1.0.28-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.27...@aws-amplify/storage@1.0.28-unstable.0) (2019-04-02) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.27"></a> | ||
## [1.0.27](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.27-unstable.2...@aws-amplify/storage@1.0.27) (2019-03-28) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.27-unstable.2"></a> | ||
## [1.0.27-unstable.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.27-unstable.1...@aws-amplify/storage@1.0.27-unstable.2) (2019-03-28) | ||
### Features | ||
* **core:** Hub refactor and tests ([7ac5bcf](https://github.com/aws/aws-amplify/commit/7ac5bcf)) | ||
- **core:** Hub refactor and tests ([7ac5bcf](https://github.com/aws/aws-amplify/commit/7ac5bcf)) | ||
<a name="1.0.27-unstable.1"></a> | ||
<a name="1.0.27-unstable.1"></a> | ||
## [1.0.27-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.27-unstable.0...@aws-amplify/storage@1.0.27-unstable.1) (2019-03-22) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.27-unstable.0"></a> | ||
## [1.0.27-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.26...@aws-amplify/storage@1.0.27-unstable.0) (2019-03-21) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.26"></a> | ||
## [1.0.26](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.26-unstable.4...@aws-amplify/storage@1.0.26) (2019-03-04) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.26-unstable.4"></a> | ||
## [1.0.26-unstable.4](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.26-unstable.3...@aws-amplify/storage@1.0.26-unstable.4) (2019-03-04) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.26-unstable.3"></a> | ||
## [1.0.26-unstable.3](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.26-unstable.2...@aws-amplify/storage@1.0.26-unstable.3) (2019-02-28) | ||
### Features | ||
* **storage:** Added tagging support on put request (S3) ([#2606](https://github.com/aws/aws-amplify/issues/2606)) ([50243b7](https://github.com/aws/aws-amplify/commit/50243b7)), closes [#2594](https://github.com/aws/aws-amplify/issues/2594) | ||
- **storage:** Added tagging support on put request (S3) ([#2606](https://github.com/aws/aws-amplify/issues/2606)) ([50243b7](https://github.com/aws/aws-amplify/commit/50243b7)), closes [#2594](https://github.com/aws/aws-amplify/issues/2594) | ||
<a name="1.0.26-unstable.2"></a> | ||
<a name="1.0.26-unstable.2"></a> | ||
## [1.0.26-unstable.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.26-unstable.1...@aws-amplify/storage@1.0.26-unstable.2) (2019-02-27) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.26-unstable.1"></a> | ||
## [1.0.26-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.26-unstable.0...@aws-amplify/storage@1.0.26-unstable.1) (2019-02-27) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.26-unstable.0"></a> | ||
## [1.0.26-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.25...@aws-amplify/storage@1.0.26-unstable.0) (2019-01-10) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.25"></a> | ||
## [1.0.25](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.25-unstable.0...@aws-amplify/storage@1.0.25) (2019-01-10) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.25-unstable.0"></a> | ||
## [1.0.25-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.24...@aws-amplify/storage@1.0.25-unstable.0) (2018-12-26) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.24"></a> | ||
## [1.0.24](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.24-unstable.1...@aws-amplify/storage@1.0.24) (2018-12-26) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.24-unstable.1"></a> | ||
## [1.0.24-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.24-unstable.0...@aws-amplify/storage@1.0.24-unstable.1) (2018-12-22) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.24-unstable.0"></a> | ||
## [1.0.24-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.23...@aws-amplify/storage@1.0.24-unstable.0) (2018-12-19) | ||
### Bug Fixes | ||
* **@aws-amplify/storage:** Explicitly declare signatureVersion 'v4' ([#2379](https://github.com/aws/aws-amplify/issues/2379)) ([32d439a](https://github.com/aws/aws-amplify/commit/32d439a)) | ||
- **@aws-amplify/storage:** Explicitly declare signatureVersion 'v4' ([#2379](https://github.com/aws/aws-amplify/issues/2379)) ([32d439a](https://github.com/aws/aws-amplify/commit/32d439a)) | ||
<a name="1.0.23"></a> | ||
<a name="1.0.23"></a> | ||
## [1.0.23](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.23-unstable.2...@aws-amplify/storage@1.0.23) (2018-12-13) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.23-unstable.2"></a> | ||
## [1.0.23-unstable.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.23-unstable.1...@aws-amplify/storage@1.0.23-unstable.2) (2018-12-13) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.23-unstable.1"></a> | ||
## [1.0.23-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.23-unstable.0...@aws-amplify/storage@1.0.23-unstable.1) (2018-12-07) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.23-unstable.0"></a> | ||
## [1.0.23-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.22...@aws-amplify/storage@1.0.23-unstable.0) (2018-12-07) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.22"></a> | ||
## [1.0.22](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.21...@aws-amplify/storage@1.0.22) (2018-12-07) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.22-unstable.0"></a> | ||
## [1.0.22-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.21...@aws-amplify/storage@1.0.22-unstable.0) (2018-12-06) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.21"></a> | ||
## [1.0.21](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.20...@aws-amplify/storage@1.0.21) (2018-12-06) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.21-unstable.0"></a> | ||
## [1.0.21-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.20...@aws-amplify/storage@1.0.21-unstable.0) (2018-12-05) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.20"></a> | ||
## [1.0.20](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.20-unstable.5...@aws-amplify/storage@1.0.20) (2018-12-03) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.20-unstable.5"></a> | ||
## [1.0.20-unstable.5](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.20-unstable.4...@aws-amplify/storage@1.0.20-unstable.5) (2018-11-29) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.20-unstable.4"></a> | ||
## [1.0.20-unstable.4](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.20-unstable.3...@aws-amplify/storage@1.0.20-unstable.4) (2018-11-27) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.20-unstable.3"></a> | ||
## [1.0.20-unstable.3](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.20-unstable.2...@aws-amplify/storage@1.0.20-unstable.3) (2018-11-26) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.20-unstable.2"></a> | ||
## [1.0.20-unstable.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.20-unstable.1...@aws-amplify/storage@1.0.20-unstable.2) (2018-11-20) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.20-unstable.1"></a> | ||
## [1.0.20-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.20-unstable.0...@aws-amplify/storage@1.0.20-unstable.1) (2018-11-19) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.20-unstable.0"></a> | ||
## [1.0.20-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.19...@aws-amplify/storage@1.0.20-unstable.0) (2018-11-15) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.19"></a> | ||
## [1.0.19](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.19-unstable.0...@aws-amplify/storage@1.0.19) (2018-11-12) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.19-unstable.0"></a> | ||
## [1.0.19-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.18...@aws-amplify/storage@1.0.19-unstable.0) (2018-11-06) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.18"></a> | ||
## [1.0.18](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.18-unstable.0...@aws-amplify/storage@1.0.18) (2018-11-01) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.18-unstable.0"></a> | ||
## [1.0.18-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.17...@aws-amplify/storage@1.0.18-unstable.0) (2018-10-30) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.17"></a> | ||
## [1.0.17](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.17-unstable.1...@aws-amplify/storage@1.0.17) (2018-10-29) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.17-unstable.1"></a> | ||
## [1.0.17-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.17-unstable.0...@aws-amplify/storage@1.0.17-unstable.1) (2018-10-18) | ||
### Bug Fixes | ||
* **storage:** Update JSDoc to clarify that Storage.get can return a Promise<String|Object> ([#1913](https://github.com/aws/aws-amplify/issues/1913)) ([dfc3bb7](https://github.com/aws/aws-amplify/commit/dfc3bb7)), closes [#1912](https://github.com/aws/aws-amplify/issues/1912) | ||
- **storage:** Update JSDoc to clarify that Storage.get can return a Promise<String|Object> ([#1913](https://github.com/aws/aws-amplify/issues/1913)) ([dfc3bb7](https://github.com/aws/aws-amplify/commit/dfc3bb7)), closes [#1912](https://github.com/aws/aws-amplify/issues/1912) | ||
<a name="1.0.17-unstable.0"></a> | ||
<a name="1.0.17-unstable.0"></a> | ||
## [1.0.17-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.16...@aws-amplify/storage@1.0.17-unstable.0) (2018-10-18) | ||
### Features | ||
* **@aws-amplify/storage:** Added ability to track progress of S3 uploads ([#1830](https://github.com/aws/aws-amplify/issues/1830)) ([5aef207](https://github.com/aws/aws-amplify/commit/5aef207)) | ||
- **@aws-amplify/storage:** Added ability to track progress of S3 uploads ([#1830](https://github.com/aws/aws-amplify/issues/1830)) ([5aef207](https://github.com/aws/aws-amplify/commit/5aef207)) | ||
<a name="1.0.16"></a> | ||
<a name="1.0.16"></a> | ||
## [1.0.16](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.16-unstable.4...@aws-amplify/storage@1.0.16) (2018-10-17) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.16-unstable.4"></a> | ||
## [1.0.16-unstable.4](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.16-unstable.3...@aws-amplify/storage@1.0.16-unstable.4) (2018-10-17) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.16-unstable.3"></a> | ||
## [1.0.16-unstable.3](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.16-unstable.2...@aws-amplify/storage@1.0.16-unstable.3) (2018-10-16) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.16-unstable.2"></a> | ||
## [1.0.16-unstable.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.16-unstable.1...@aws-amplify/storage@1.0.16-unstable.2) (2018-10-08) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.16-unstable.1"></a> | ||
## [1.0.16-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.16-unstable.0...@aws-amplify/storage@1.0.16-unstable.1) (2018-10-05) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.16-unstable.0"></a> | ||
## [1.0.16-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.15-unstable.1...@aws-amplify/storage@1.0.16-unstable.0) (2018-10-05) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.15"></a> | ||
## [1.0.15](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.15-unstable.1...@aws-amplify/storage@1.0.15) (2018-10-04) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.15-unstable.1"></a> | ||
## [1.0.15-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.15-unstable.0...@aws-amplify/storage@1.0.15-unstable.1) (2018-10-03) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.15-unstable.0"></a> | ||
## [1.0.15-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.14-unstable.1...@aws-amplify/storage@1.0.15-unstable.0) (2018-10-03) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.14"></a> | ||
## [1.0.14](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.14-unstable.1...@aws-amplify/storage@1.0.14) (2018-10-03) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.14-unstable.1"></a> | ||
## [1.0.14-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.14-unstable.0...@aws-amplify/storage@1.0.14-unstable.1) (2018-10-01) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.14-unstable.0"></a> | ||
## [1.0.14-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.13...@aws-amplify/storage@1.0.14-unstable.0) (2018-09-28) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.13"></a> | ||
## [1.0.13](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.13-unstable.1...@aws-amplify/storage@1.0.13) (2018-09-27) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.13-unstable.1"></a> | ||
## [1.0.13-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.13-unstable.0...@aws-amplify/storage@1.0.13-unstable.1) (2018-09-25) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.13-unstable.0"></a> | ||
## [1.0.13-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.12...@aws-amplify/storage@1.0.13-unstable.0) (2018-09-22) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.12"></a> | ||
## [1.0.12](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.12-unstable.0...@aws-amplify/storage@1.0.12) (2018-09-21) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.12-unstable.0"></a> | ||
## [1.0.12-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.10...@aws-amplify/storage@1.0.12-unstable.0) (2018-09-21) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.11"></a> | ||
## [1.0.11](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.10...@aws-amplify/storage@1.0.11) (2018-09-21) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.10"></a> | ||
## [1.0.10](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.9...@aws-amplify/storage@1.0.10) (2018-09-17) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.9"></a> | ||
## [1.0.9](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.8...@aws-amplify/storage@1.0.9) (2018-09-12) | ||
### Bug Fixes | ||
* **aws-amplify:** update the version of aws-sdk to latest ([482402d](https://github.com/aws/aws-amplify/commit/482402d)) | ||
- **aws-amplify:** update the version of aws-sdk to latest ([482402d](https://github.com/aws/aws-amplify/commit/482402d)) | ||
<a name="1.0.8"></a> | ||
<a name="1.0.8"></a> | ||
## [1.0.8](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.7...@aws-amplify/storage@1.0.8) (2018-09-09) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.8-unstable.1"></a> | ||
## [1.0.8-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.7...@aws-amplify/storage@1.0.8-unstable.1) (2018-08-30) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.7"></a> | ||
## [1.0.7](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.6-unstable.1...@aws-amplify/storage@1.0.7) (2018-08-28) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.6-unstable.1"></a> | ||
## [1.0.6-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.6-unstable.0...@aws-amplify/storage@1.0.6-unstable.1) (2018-08-20) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.6-unstable.0"></a> | ||
## [1.0.6-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.5...@aws-amplify/storage@1.0.6-unstable.0) (2018-08-19) | ||
### Bug Fixes | ||
* **aws-amplify-angular:** Angular rollup ([#1441](https://github.com/aws/aws-amplify/issues/1441)) ([eb84e01](https://github.com/aws/aws-amplify/commit/eb84e01)) | ||
- **aws-amplify-angular:** Angular rollup ([#1441](https://github.com/aws/aws-amplify/issues/1441)) ([eb84e01](https://github.com/aws/aws-amplify/commit/eb84e01)) | ||
<a name="1.0.5"></a> | ||
<a name="1.0.5"></a> | ||
## [1.0.5](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.5-unstable.0...@aws-amplify/storage@1.0.5) (2018-08-14) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.5-unstable.0"></a> | ||
## [1.0.5-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.4...@aws-amplify/storage@1.0.5-unstable.0) (2018-08-09) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.4"></a> | ||
## [1.0.4](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.3-unstable.1...@aws-amplify/storage@1.0.4) (2018-08-06) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.3-unstable.1"></a> | ||
## [1.0.3-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.3...@aws-amplify/storage@1.0.3-unstable.1) (2018-08-06) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.3"></a> | ||
## [1.0.3](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.3-unstable.0...@aws-amplify/storage@1.0.3) (2018-07-28) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.3-unstable.0"></a> | ||
## [1.0.3-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.2...@aws-amplify/storage@1.0.3-unstable.0) (2018-07-26) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.2"></a> | ||
## [1.0.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.2-unstable.0...@aws-amplify/storage@1.0.2) (2018-07-19) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.2-unstable.0"></a> | ||
## [1.0.2-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.1...@aws-amplify/storage@1.0.2-unstable.0) (2018-07-19) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.1"></a> | ||
## [1.0.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.1-unstable.2...@aws-amplify/storage@1.0.1) (2018-07-18) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.1-unstable.2"></a> | ||
## [1.0.1-unstable.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.1-unstable.1...@aws-amplify/storage@1.0.1-unstable.2) (2018-07-18) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.1-unstable.1"></a> | ||
## [1.0.1-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.1...@aws-amplify/storage@1.0.1-unstable.1) (2018-07-18) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="1.0.1-unstable.0"></a> | ||
## [1.0.1-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/storage@1.0.1...@aws-amplify/storage@1.0.1-unstable.0) (2018-07-18) | ||
**Note:** Version bump only for package @aws-amplify/storage | ||
<a name="0.1.1-unstable.0"></a> | ||
## 0.1.1-unstable.0 (2018-06-27) | ||
**Note:** Version bump only for package @aws-amplify/storage |
@@ -42,3 +42,3 @@ "use strict"; | ||
if (typeof vaultConfig[providerName] !== 'string') { | ||
vaultConfig[providerName] = __assign({}, vaultConfig[providerName], { level: "private" }); | ||
vaultConfig[providerName] = __assign({}, vaultConfig[providerName], { level: 'private' }); | ||
} | ||
@@ -45,0 +45,0 @@ }); |
@@ -32,8 +32,8 @@ import { StorageOptions, StorageProvider } from '../types'; | ||
/** | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to Amazon S3 presigned URL on success | ||
*/ | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to Amazon S3 presigned URL on success | ||
*/ | ||
get(key: string, config?: any): Promise<String | Object>; | ||
@@ -40,0 +40,0 @@ /** |
@@ -61,4 +61,6 @@ "use strict"; | ||
var logger = new core_1.ConsoleLogger('AWSS3Provider'); | ||
var AMPLIFY_SYMBOL = ((typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') ? | ||
Symbol.for('amplify_default') : '@@amplify_default'); | ||
var AMPLIFY_SYMBOL = (typeof Symbol !== 'undefined' && | ||
typeof Symbol.for === 'function' | ||
? Symbol.for('amplify_default') | ||
: '@@amplify_default'); | ||
var dispatchStorageEvent = function (track, event, attrs, metrics, message) { | ||
@@ -69,3 +71,3 @@ if (track) { | ||
data: { attrs: attrs, metrics: metrics }, | ||
message: message | ||
message: message, | ||
}, 'Storage', AMPLIFY_SYMBOL); | ||
@@ -116,8 +118,8 @@ } | ||
/** | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to Amazon S3 presigned URL on success | ||
*/ | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to Amazon S3 presigned URL on success | ||
*/ | ||
AWSS3Provider.prototype.get = function (key, config) { | ||
@@ -142,3 +144,3 @@ return __awaiter(this, void 0, void 0, function () { | ||
Bucket: bucket, | ||
Key: final_key | ||
Key: final_key, | ||
}; | ||
@@ -151,3 +153,3 @@ if (download === true) { | ||
method: 'get', | ||
result: 'failed' | ||
result: 'failed', | ||
}, null, "Download failed with " + err.message); | ||
@@ -214,3 +216,3 @@ rej(err); | ||
Body: object, | ||
ContentType: type | ||
ContentType: type, | ||
}; | ||
@@ -250,5 +252,3 @@ if (cacheControl) { | ||
_a.trys.push([2, 4, , 5]); | ||
upload = s3 | ||
.upload(params) | ||
.on('httpUploadProgress', function (progress) { | ||
upload = s3.upload(params).on('httpUploadProgress', function (progress) { | ||
if (progressCallback) { | ||
@@ -259,3 +259,4 @@ if (typeof progressCallback === 'function') { | ||
else { | ||
logger.warn('progressCallback should be a function, not a ' + typeof progressCallback); | ||
logger.warn('progressCallback should be a function, not a ' + | ||
typeof progressCallback); | ||
} | ||
@@ -270,7 +271,7 @@ } | ||
return [2 /*return*/, { | ||
key: data.Key.substr(prefix.length) | ||
key: data.Key.substr(prefix.length), | ||
}]; | ||
case 4: | ||
e_1 = _a.sent(); | ||
logger.warn("error uploading", e_1); | ||
logger.warn('error uploading', e_1); | ||
dispatchStorageEvent(track, 'upload', { method: 'put', result: 'failed' }, null, "Error uploading " + key); | ||
@@ -308,3 +309,3 @@ throw e_1; | ||
Bucket: bucket, | ||
Key: final_key | ||
Key: final_key, | ||
}; | ||
@@ -352,3 +353,3 @@ return [2 /*return*/, new Promise(function (res, rej) { | ||
Bucket: bucket, | ||
Prefix: final_path | ||
Prefix: final_path, | ||
}; | ||
@@ -368,3 +369,3 @@ return [2 /*return*/, new Promise(function (res, rej) { | ||
lastModified: item.LastModified, | ||
size: item.Size | ||
size: item.Size, | ||
}; | ||
@@ -408,5 +409,10 @@ }); | ||
var identityId = config.identityId || credentials.identityId; | ||
var privatePath = (customPrefix.private !== undefined ? customPrefix.private : 'private/') + identityId + '/'; | ||
var protectedPath = (customPrefix.protected !== undefined ? | ||
customPrefix.protected : 'protected/') + identityId + '/'; | ||
var privatePath = (customPrefix.private !== undefined ? customPrefix.private : 'private/') + | ||
identityId + | ||
'/'; | ||
var protectedPath = (customPrefix.protected !== undefined | ||
? customPrefix.protected | ||
: 'protected/') + | ||
identityId + | ||
'/'; | ||
var publicPath = customPrefix.public !== undefined ? customPrefix.public : 'public/'; | ||
@@ -432,3 +438,3 @@ switch (level) { | ||
s3BucketEndpoint: true, | ||
s3ForcePathStyle: true | ||
s3ForcePathStyle: true, | ||
}; | ||
@@ -435,0 +441,0 @@ } |
@@ -43,8 +43,8 @@ import { StorageProvider } from './types'; | ||
/** | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to either a presigned url or the object | ||
*/ | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to either a presigned url or the object | ||
*/ | ||
get(key: string, config?: any): Promise<String | Object>; | ||
@@ -51,0 +51,0 @@ /** |
@@ -137,6 +137,10 @@ "use strict"; | ||
'SSECustomerKeyMD5', | ||
'SSEKMSKeyId' | ||
'SSEKMSKeyId', | ||
]; | ||
var isInStorageArrayKeys = function (k) { return storageArrayKeys.some(function (x) { return x === k; }); }; | ||
var checkConfigKeysFromArray = function (k) { return k.find(function (k) { return isInStorageArrayKeys(k); }); }; | ||
var isInStorageArrayKeys = function (k) { | ||
return storageArrayKeys.some(function (x) { return x === k; }); | ||
}; | ||
var checkConfigKeysFromArray = function (k) { | ||
return k.find(function (k) { return isInStorageArrayKeys(k); }); | ||
}; | ||
if (storageKeysFromConfig && | ||
@@ -169,8 +173,8 @@ checkConfigKeysFromArray(storageKeysFromConfig) && | ||
/** | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to either a presigned url or the object | ||
*/ | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to either a presigned url or the object | ||
*/ | ||
StorageClass.prototype.get = function (key, config) { | ||
@@ -177,0 +181,0 @@ return __awaiter(this, void 0, void 0, function () { |
{ | ||
"name": "@aws-amplify/storage", | ||
"version": "1.1.3-unstable.11+40f9a4dd", | ||
"version": "1.1.3-unstable.12+ec36f8d7", | ||
"description": "Storage category of aws-amplify", | ||
@@ -52,3 +52,3 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"@aws-amplify/core": "1.1.3-unstable.11+40f9a4dd" | ||
"@aws-amplify/core": "1.1.3-unstable.12+ec36f8d7" | ||
}, | ||
@@ -81,3 +81,3 @@ "jest": { | ||
}, | ||
"gitHead": "40f9a4dd6613004b2b94e0f06612331bfad9c92a" | ||
"gitHead": "ec36f8d76efc0bcf3c911277a7cc480a8f073a0c" | ||
} |
@@ -24,20 +24,23 @@ /* | ||
if (!_instance) { | ||
logger.debug('Create Storage Instance'); | ||
_instance = new StorageClass(); | ||
_instance.vault = new StorageClass(); | ||
const old_configure = _instance.configure; | ||
_instance.configure = (options) => { | ||
logger.debug('storage configure called'); | ||
const vaultConfig = {...old_configure.call(_instance, options)}; | ||
logger.debug('Create Storage Instance'); | ||
_instance = new StorageClass(); | ||
_instance.vault = new StorageClass(); | ||
// set level private for each provider for the vault | ||
Object.keys(vaultConfig).forEach((providerName) => { | ||
if (typeof vaultConfig[providerName] !== 'string') { | ||
vaultConfig[providerName] = { ...vaultConfig[providerName], level: "private" }; | ||
} | ||
}); | ||
logger.debug('storage vault configure called'); | ||
_instance.vault.configure(vaultConfig); | ||
}; | ||
const old_configure = _instance.configure; | ||
_instance.configure = options => { | ||
logger.debug('storage configure called'); | ||
const vaultConfig = { ...old_configure.call(_instance, options) }; | ||
// set level private for each provider for the vault | ||
Object.keys(vaultConfig).forEach(providerName => { | ||
if (typeof vaultConfig[providerName] !== 'string') { | ||
vaultConfig[providerName] = { | ||
...vaultConfig[providerName], | ||
level: 'private', | ||
}; | ||
} | ||
}); | ||
logger.debug('storage vault configure called'); | ||
_instance.vault.configure(vaultConfig); | ||
}; | ||
} | ||
@@ -44,0 +47,0 @@ |
@@ -14,6 +14,6 @@ /* | ||
import { | ||
ConsoleLogger as Logger, | ||
Hub, | ||
Credentials, | ||
Parser | ||
ConsoleLogger as Logger, | ||
Hub, | ||
Credentials, | ||
Parser, | ||
} from '@aws-amplify/core'; | ||
@@ -25,18 +25,26 @@ import * as S3 from 'aws-sdk/clients/s3'; | ||
const AMPLIFY_SYMBOL = ((typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') ? | ||
Symbol.for('amplify_default') : '@@amplify_default') as Symbol; | ||
const AMPLIFY_SYMBOL = (typeof Symbol !== 'undefined' && | ||
typeof Symbol.for === 'function' | ||
? Symbol.for('amplify_default') | ||
: '@@amplify_default') as Symbol; | ||
const dispatchStorageEvent = (track:boolean, event:string, attrs:any, metrics:any, message:string) => { | ||
if (track) { | ||
Hub.dispatch( | ||
'storage', | ||
{ | ||
event, | ||
data: { attrs, metrics }, | ||
message | ||
}, | ||
'Storage', | ||
AMPLIFY_SYMBOL | ||
); | ||
} | ||
const dispatchStorageEvent = ( | ||
track: boolean, | ||
event: string, | ||
attrs: any, | ||
metrics: any, | ||
message: string | ||
) => { | ||
if (track) { | ||
Hub.dispatch( | ||
'storage', | ||
{ | ||
event, | ||
data: { attrs, metrics }, | ||
message, | ||
}, | ||
'Storage', | ||
AMPLIFY_SYMBOL | ||
); | ||
} | ||
}; | ||
@@ -49,388 +57,438 @@ | ||
*/ | ||
export default class AWSS3Provider implements StorageProvider{ | ||
export default class AWSS3Provider implements StorageProvider { | ||
static CATEGORY = 'Storage'; | ||
static PROVIDER_NAME = 'AWSS3'; | ||
static CATEGORY = 'Storage'; | ||
static PROVIDER_NAME = 'AWSS3'; | ||
/** | ||
* @private | ||
*/ | ||
private _config; | ||
/** | ||
* @private | ||
*/ | ||
private _config; | ||
/** | ||
* Initialize Storage with AWS configurations | ||
* @param {Object} config - Configuration object for storage | ||
*/ | ||
constructor(config?: StorageOptions) { | ||
this._config = config ? config : {}; | ||
logger.debug('Storage Options', this._config); | ||
} | ||
/** | ||
* Initialize Storage with AWS configurations | ||
* @param {Object} config - Configuration object for storage | ||
*/ | ||
constructor(config?: StorageOptions) { | ||
this._config = config ? config: {}; | ||
logger.debug('Storage Options', this._config); | ||
} | ||
/** | ||
* get the category of the plugin | ||
*/ | ||
public getCategory(): string { | ||
return AWSS3Provider.CATEGORY; | ||
} | ||
/** | ||
* get the category of the plugin | ||
*/ | ||
public getCategory(): string { | ||
return AWSS3Provider.CATEGORY; | ||
} | ||
/** | ||
* get provider name of the plugin | ||
*/ | ||
getProviderName(): string { | ||
return AWSS3Provider.PROVIDER_NAME; | ||
} | ||
/** | ||
* get provider name of the plugin | ||
*/ | ||
getProviderName(): string { | ||
return AWSS3Provider.PROVIDER_NAME; | ||
} | ||
/** | ||
* Configure Storage part with aws configuration | ||
* @param {Object} config - Configuration of the Storage | ||
* @return {Object} - Current configuration | ||
*/ | ||
public configure(config?): object { | ||
logger.debug('configure Storage', config); | ||
if (!config) return this._config; | ||
const amplifyConfig = Parser.parseMobilehubConfig(config); | ||
this._config = Object.assign({}, this._config, amplifyConfig.Storage); | ||
if (!this._config.bucket) { | ||
logger.debug('Do not have bucket yet'); | ||
} | ||
return this._config; | ||
} | ||
/** | ||
* Configure Storage part with aws configuration | ||
* @param {Object} config - Configuration of the Storage | ||
* @return {Object} - Current configuration | ||
*/ | ||
public configure(config?): object { | ||
logger.debug('configure Storage', config); | ||
if (!config) return this._config; | ||
const amplifyConfig = Parser.parseMobilehubConfig(config); | ||
this._config = Object.assign({}, this._config, amplifyConfig.Storage); | ||
if (!this._config.bucket) { logger.debug('Do not have bucket yet'); } | ||
return this._config; | ||
} | ||
/** | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to Amazon S3 presigned URL on success | ||
*/ | ||
public async get(key: string, config?): Promise<String | Object> { | ||
const credentialsOK = await this._ensureCredentials(); | ||
if (!credentialsOK) { | ||
return Promise.reject('No credentials'); | ||
} | ||
/** | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to Amazon S3 presigned URL on success | ||
*/ | ||
public async get(key: string, config?): Promise<String|Object> { | ||
const credentialsOK = await this._ensureCredentials(); | ||
if (!credentialsOK) { return Promise.reject('No credentials'); } | ||
const opt = Object.assign({}, this._config, config); | ||
const { bucket, download, track, expires } = opt; | ||
const prefix = this._prefix(opt); | ||
const final_key = prefix + key; | ||
const s3 = this._createS3(opt); | ||
logger.debug('get ' + key + ' from ' + final_key); | ||
const opt = Object.assign({}, this._config, config); | ||
const { bucket, download, track, expires } = opt; | ||
const prefix = this._prefix(opt); | ||
const final_key = prefix + key; | ||
const s3 = this._createS3(opt); | ||
logger.debug('get ' + key + ' from ' + final_key); | ||
const params: any = { | ||
Bucket: bucket, | ||
Key: final_key, | ||
}; | ||
const params: any = { | ||
Bucket: bucket, | ||
Key: final_key | ||
}; | ||
if (download === true) { | ||
return new Promise<any>((res, rej) => { | ||
s3.getObject(params, (err, data) => { | ||
if (err) { | ||
dispatchStorageEvent( | ||
track, | ||
'download', | ||
{ | ||
method: 'get', | ||
result: 'failed', | ||
}, | ||
null, | ||
`Download failed with ${err.message}` | ||
); | ||
rej(err); | ||
} else { | ||
dispatchStorageEvent( | ||
track, | ||
'download', | ||
{ method: 'get', result: 'success' }, | ||
{ fileSize: Number(data.Body['length']) }, | ||
`Download success for ${key}` | ||
); | ||
res(data); | ||
} | ||
}); | ||
}); | ||
} | ||
if (download === true) { | ||
return new Promise<any>((res, rej) => { | ||
s3.getObject(params, (err, data) => { | ||
if (err) { | ||
dispatchStorageEvent( | ||
track, | ||
'download', | ||
{ | ||
method: 'get', | ||
result: 'failed' | ||
}, | ||
null, | ||
`Download failed with ${err.message}` | ||
); | ||
rej(err); | ||
} else { | ||
dispatchStorageEvent( | ||
track, | ||
'download', | ||
{ method: 'get', result: 'success' }, | ||
{ fileSize: Number(data.Body['length']) }, | ||
`Download success for ${key}` | ||
); | ||
res(data); | ||
} | ||
}); | ||
}); | ||
} | ||
if (expires) { | ||
params.Expires = expires; | ||
} | ||
if (expires) { params.Expires = expires; } | ||
return new Promise<string>((res, rej) => { | ||
try { | ||
const url = s3.getSignedUrl('getObject', params); | ||
dispatchStorageEvent( | ||
track, | ||
'getSignedUrl', | ||
{ method: 'get', result: 'success' }, | ||
null, | ||
`Signed URL: ${url}` | ||
); | ||
res(url); | ||
} catch (e) { | ||
logger.warn('get signed url error', e); | ||
dispatchStorageEvent( | ||
track, | ||
'getSignedUrl', | ||
{ method: 'get', result: 'failed' }, | ||
null, | ||
`Could not get a signed URL for ${key}` | ||
); | ||
rej(e); | ||
} | ||
}); | ||
} | ||
return new Promise<string>((res, rej) => { | ||
try { | ||
const url = s3.getSignedUrl('getObject', params); | ||
dispatchStorageEvent( | ||
track, | ||
'getSignedUrl', | ||
{ method: 'get', result: 'success' }, | ||
null, | ||
`Signed URL: ${url}` | ||
); | ||
res(url); | ||
} catch (e) { | ||
logger.warn('get signed url error', e); | ||
dispatchStorageEvent( | ||
track, | ||
'getSignedUrl', | ||
{ method: 'get', result: 'failed' }, | ||
null, | ||
`Could not get a signed URL for ${key}` | ||
); | ||
rej(e); | ||
} | ||
}); | ||
} | ||
/** | ||
* Put a file in S3 bucket specified to configure method | ||
* @param {String} key - key of the object | ||
* @param {Object} object - File to be put in Amazon S3 bucket | ||
* @param {Object} [config] - { level : private|protected|public, contentType: MIME Types, | ||
* progressCallback: function } | ||
* @return - promise resolves to object on success | ||
*/ | ||
public async put(key: string, object, config?): Promise<Object> { | ||
const credentialsOK = await this._ensureCredentials(); | ||
if (!credentialsOK) { | ||
return Promise.reject('No credentials'); | ||
} | ||
/** | ||
* Put a file in S3 bucket specified to configure method | ||
* @param {String} key - key of the object | ||
* @param {Object} object - File to be put in Amazon S3 bucket | ||
* @param {Object} [config] - { level : private|protected|public, contentType: MIME Types, | ||
* progressCallback: function } | ||
* @return - promise resolves to object on success | ||
*/ | ||
public async put(key: string, object, config?): Promise<Object> { | ||
const credentialsOK = await this._ensureCredentials(); | ||
if (!credentialsOK) { return Promise.reject('No credentials'); } | ||
const opt = Object.assign({}, this._config, config); | ||
const { bucket, track, progressCallback } = opt; | ||
const { | ||
contentType, | ||
contentDisposition, | ||
cacheControl, | ||
expires, | ||
metadata, | ||
tagging, | ||
} = opt; | ||
const { | ||
serverSideEncryption, | ||
SSECustomerAlgorithm, | ||
SSECustomerKey, | ||
SSECustomerKeyMD5, | ||
SSEKMSKeyId, | ||
} = opt; | ||
const type = contentType ? contentType : 'binary/octet-stream'; | ||
const opt = Object.assign({}, this._config, config); | ||
const { bucket, track, progressCallback } = opt; | ||
const { contentType, contentDisposition, cacheControl, expires, metadata, tagging } = opt; | ||
const { serverSideEncryption, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId } = opt; | ||
const type = contentType ? contentType : 'binary/octet-stream'; | ||
const prefix = this._prefix(opt); | ||
const final_key = prefix + key; | ||
const s3 = this._createS3(opt); | ||
logger.debug('put ' + key + ' to ' + final_key); | ||
const prefix = this._prefix(opt); | ||
const final_key = prefix + key; | ||
const s3 = this._createS3(opt); | ||
logger.debug('put ' + key + ' to ' + final_key); | ||
const params: any = { | ||
Bucket: bucket, | ||
Key: final_key, | ||
Body: object, | ||
ContentType: type, | ||
}; | ||
if (cacheControl) { | ||
params.CacheControl = cacheControl; | ||
} | ||
if (contentDisposition) { | ||
params.ContentDisposition = contentDisposition; | ||
} | ||
if (expires) { | ||
params.Expires = expires; | ||
} | ||
if (metadata) { | ||
params.Metadata = metadata; | ||
} | ||
if (tagging) { | ||
params.Tagging = tagging; | ||
} | ||
if (serverSideEncryption) { | ||
params.ServerSideEncryption = serverSideEncryption; | ||
if (SSECustomerAlgorithm) { | ||
params.SSECustomerAlgorithm = SSECustomerAlgorithm; | ||
} | ||
if (SSECustomerKey) { | ||
params.SSECustomerKey = SSECustomerKey; | ||
} | ||
if (SSECustomerKeyMD5) { | ||
params.SSECustomerKeyMD5 = SSECustomerKeyMD5; | ||
} | ||
if (SSEKMSKeyId) { | ||
params.SSEKMSKeyId = SSEKMSKeyId; | ||
} | ||
} | ||
const params: any = { | ||
Bucket: bucket, | ||
Key: final_key, | ||
Body: object, | ||
ContentType: type | ||
}; | ||
if (cacheControl) { params.CacheControl = cacheControl; } | ||
if (contentDisposition) { params.ContentDisposition = contentDisposition; } | ||
if (expires) { params.Expires = expires; } | ||
if (metadata) { params.Metadata = metadata; } | ||
if (tagging) { params.Tagging = tagging; } | ||
if (serverSideEncryption) { | ||
params.ServerSideEncryption = serverSideEncryption; | ||
if (SSECustomerAlgorithm) { params.SSECustomerAlgorithm = SSECustomerAlgorithm; } | ||
if (SSECustomerKey) { params.SSECustomerKey = SSECustomerKey; } | ||
if (SSECustomerKeyMD5) { params.SSECustomerKeyMD5 = SSECustomerKeyMD5; } | ||
if (SSEKMSKeyId) { params.SSEKMSKeyId = SSEKMSKeyId; } | ||
} | ||
try { | ||
const upload = s3.upload(params).on('httpUploadProgress', progress => { | ||
if (progressCallback) { | ||
if (typeof progressCallback === 'function') { | ||
progressCallback(progress); | ||
} else { | ||
logger.warn( | ||
'progressCallback should be a function, not a ' + | ||
typeof progressCallback | ||
); | ||
} | ||
} | ||
}); | ||
const data = await upload.promise(); | ||
try { | ||
const upload = s3 | ||
.upload(params) | ||
.on('httpUploadProgress', progress => { | ||
if (progressCallback) { | ||
if (typeof progressCallback === 'function') { | ||
progressCallback(progress); | ||
} else { | ||
logger.warn('progressCallback should be a function, not a ' + typeof progressCallback); | ||
} | ||
} | ||
}); | ||
const data = await upload.promise(); | ||
logger.debug('upload result', data); | ||
dispatchStorageEvent( | ||
track, | ||
'upload', | ||
{ method: 'put', result: 'success' }, | ||
null, | ||
`Upload success for ${key}` | ||
); | ||
logger.debug('upload result', data); | ||
dispatchStorageEvent( | ||
track, | ||
'upload', | ||
{ method: 'put', result: 'success' }, | ||
null, | ||
`Upload success for ${key}` | ||
); | ||
return { | ||
key: data.Key.substr(prefix.length), | ||
}; | ||
} catch (e) { | ||
logger.warn('error uploading', e); | ||
dispatchStorageEvent( | ||
track, | ||
'upload', | ||
{ method: 'put', result: 'failed' }, | ||
null, | ||
`Error uploading ${key}` | ||
); | ||
return { | ||
key: data.Key.substr(prefix.length) | ||
}; | ||
} catch (e) { | ||
logger.warn("error uploading", e); | ||
dispatchStorageEvent( | ||
track, | ||
'upload', | ||
{ method: 'put', result: 'failed' }, | ||
null, | ||
`Error uploading ${key}` | ||
); | ||
throw e; | ||
} | ||
} | ||
throw e; | ||
} | ||
} | ||
/** | ||
* Remove the object for specified key | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public } | ||
* @return - Promise resolves upon successful removal of the object | ||
*/ | ||
public async remove(key: string, config?): Promise<any> { | ||
const credentialsOK = await this._ensureCredentials(); | ||
if (!credentialsOK) { | ||
return Promise.reject('No credentials'); | ||
} | ||
/** | ||
* Remove the object for specified key | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public } | ||
* @return - Promise resolves upon successful removal of the object | ||
*/ | ||
public async remove(key: string, config?): Promise<any> { | ||
const credentialsOK = await this._ensureCredentials(); | ||
if (!credentialsOK) { return Promise.reject('No credentials'); } | ||
const opt = Object.assign({}, this._config, config); | ||
const { bucket, track } = opt; | ||
const opt = Object.assign({}, this._config, config, ); | ||
const { bucket, track } = opt; | ||
const prefix = this._prefix(opt); | ||
const final_key = prefix + key; | ||
const s3 = this._createS3(opt); | ||
logger.debug('remove ' + key + ' from ' + final_key); | ||
const prefix = this._prefix(opt); | ||
const final_key = prefix + key; | ||
const s3 = this._createS3(opt); | ||
logger.debug('remove ' + key + ' from ' + final_key); | ||
const params = { | ||
Bucket: bucket, | ||
Key: final_key, | ||
}; | ||
const params = { | ||
Bucket: bucket, | ||
Key: final_key | ||
}; | ||
return new Promise<any>((res, rej) => { | ||
s3.deleteObject(params, (err, data) => { | ||
if (err) { | ||
dispatchStorageEvent( | ||
track, | ||
'delete', | ||
{ method: 'remove', result: 'failed' }, | ||
null, | ||
`Deletion of ${key} failed with ${err}` | ||
); | ||
rej(err); | ||
} else { | ||
dispatchStorageEvent( | ||
track, | ||
'delete', | ||
{ method: 'remove', result: 'success' }, | ||
null, | ||
`Deleted ${key} successfully` | ||
); | ||
res(data); | ||
} | ||
}); | ||
}); | ||
} | ||
return new Promise<any>((res, rej) => { | ||
s3.deleteObject(params, (err, data) => { | ||
if (err) { | ||
dispatchStorageEvent( | ||
track, | ||
'delete', | ||
{ method: 'remove', result: 'failed' }, | ||
null, | ||
`Deletion of ${key} failed with ${err}` | ||
); | ||
rej(err); | ||
} else { | ||
dispatchStorageEvent( | ||
track, | ||
'delete', | ||
{ method: 'remove', result: 'success' }, | ||
null, | ||
`Deleted ${key} successfully` | ||
); | ||
res(data); | ||
} | ||
}); | ||
}); | ||
} | ||
/** | ||
* List bucket objects relative to the level and prefix specified | ||
* @param {String} path - the path that contains objects | ||
* @param {Object} [config] - { level : private|protected|public } | ||
* @return - Promise resolves to list of keys for all objects in path | ||
*/ | ||
public async list(path, config?): Promise<any> { | ||
const credentialsOK = await this._ensureCredentials(); | ||
if (!credentialsOK) { | ||
return Promise.reject('No credentials'); | ||
} | ||
/** | ||
* List bucket objects relative to the level and prefix specified | ||
* @param {String} path - the path that contains objects | ||
* @param {Object} [config] - { level : private|protected|public } | ||
* @return - Promise resolves to list of keys for all objects in path | ||
*/ | ||
public async list(path, config?): Promise<any> { | ||
const credentialsOK = await this._ensureCredentials(); | ||
if (!credentialsOK) { return Promise.reject('No credentials'); } | ||
const opt = Object.assign({}, this._config, config); | ||
const { bucket, track } = opt; | ||
const opt = Object.assign({}, this._config, config); | ||
const { bucket, track } = opt; | ||
const prefix = this._prefix(opt); | ||
const final_path = prefix + path; | ||
const s3 = this._createS3(opt); | ||
logger.debug('list ' + path + ' from ' + final_path); | ||
const prefix = this._prefix(opt); | ||
const final_path = prefix + path; | ||
const s3 = this._createS3(opt); | ||
logger.debug('list ' + path + ' from ' + final_path); | ||
const params = { | ||
Bucket: bucket, | ||
Prefix: final_path, | ||
}; | ||
const params = { | ||
Bucket: bucket, | ||
Prefix: final_path | ||
}; | ||
return new Promise<any>((res, rej) => { | ||
s3.listObjects(params, (err, data) => { | ||
if (err) { | ||
logger.warn('list error', err); | ||
dispatchStorageEvent( | ||
track, | ||
'list', | ||
{ method: 'list', result: 'failed' }, | ||
null, | ||
`Listing items failed: ${err.message}` | ||
); | ||
rej(err); | ||
} else { | ||
const list = data.Contents.map(item => { | ||
return { | ||
key: item.Key.substr(prefix.length), | ||
eTag: item.ETag, | ||
lastModified: item.LastModified, | ||
size: item.Size, | ||
}; | ||
}); | ||
dispatchStorageEvent( | ||
track, | ||
'list', | ||
{ method: 'list', result: 'success' }, | ||
null, | ||
`${list.length} items returned from list operation` | ||
); | ||
logger.debug('list', list); | ||
res(list); | ||
} | ||
}); | ||
}); | ||
} | ||
return new Promise<any>((res, rej) => { | ||
s3.listObjects(params, (err, data) => { | ||
if (err) { | ||
logger.warn('list error', err); | ||
dispatchStorageEvent( | ||
track, | ||
'list', | ||
{ method: 'list', result: 'failed' }, | ||
null, | ||
`Listing items failed: ${err.message}` | ||
); | ||
rej(err); | ||
} else { | ||
const list = data.Contents.map(item => { | ||
return { | ||
key: item.Key.substr(prefix.length), | ||
eTag: item.ETag, | ||
lastModified: item.LastModified, | ||
size: item.Size | ||
}; | ||
}); | ||
dispatchStorageEvent( | ||
track, | ||
'list', | ||
{ method: 'list', result: 'success' }, | ||
null, | ||
`${list.length} items returned from list operation` | ||
); | ||
logger.debug('list', list); | ||
res(list); | ||
} | ||
}); | ||
}); | ||
} | ||
/** | ||
* @private | ||
*/ | ||
_ensureCredentials() { | ||
return Credentials.get() | ||
.then(credentials => { | ||
if (!credentials) return false; | ||
const cred = Credentials.shear(credentials); | ||
logger.debug('set credentials for storage', cred); | ||
this._config.credentials = cred; | ||
/** | ||
* @private | ||
*/ | ||
_ensureCredentials() { | ||
return true; | ||
}) | ||
.catch(err => { | ||
logger.warn('ensure credentials error', err); | ||
return false; | ||
}); | ||
} | ||
return Credentials.get() | ||
.then(credentials => { | ||
if (!credentials) return false; | ||
const cred = Credentials.shear(credentials); | ||
logger.debug('set credentials for storage', cred); | ||
this._config.credentials = cred; | ||
/** | ||
* @private | ||
*/ | ||
private _prefix(config) { | ||
const { credentials, level } = config; | ||
return true; | ||
}) | ||
.catch(err => { | ||
logger.warn('ensure credentials error', err); | ||
return false; | ||
}); | ||
} | ||
const customPrefix = config.customPrefix || {}; | ||
const identityId = config.identityId || credentials.identityId; | ||
const privatePath = | ||
(customPrefix.private !== undefined ? customPrefix.private : 'private/') + | ||
identityId + | ||
'/'; | ||
const protectedPath = | ||
(customPrefix.protected !== undefined | ||
? customPrefix.protected | ||
: 'protected/') + | ||
identityId + | ||
'/'; | ||
const publicPath = | ||
customPrefix.public !== undefined ? customPrefix.public : 'public/'; | ||
/** | ||
* @private | ||
*/ | ||
private _prefix(config) { | ||
const { credentials, level } = config; | ||
switch (level) { | ||
case 'private': | ||
return privatePath; | ||
case 'protected': | ||
return protectedPath; | ||
default: | ||
return publicPath; | ||
} | ||
} | ||
const customPrefix = config.customPrefix || {}; | ||
const identityId = config.identityId || credentials.identityId; | ||
const privatePath = (customPrefix.private !== undefined ? customPrefix.private : 'private/') + identityId + '/'; | ||
const protectedPath = (customPrefix.protected !== undefined ? | ||
customPrefix.protected : 'protected/') + identityId + '/'; | ||
const publicPath = customPrefix.public !== undefined ? customPrefix.public : 'public/'; | ||
/** | ||
* @private | ||
*/ | ||
private _createS3(config) { | ||
const { | ||
bucket, | ||
region, | ||
credentials, | ||
dangerouslyConnectToHttpEndpointForTesting, | ||
} = config; | ||
let localTestingConfig = {}; | ||
switch (level) { | ||
case 'private': | ||
return privatePath; | ||
case 'protected': | ||
return protectedPath; | ||
default: | ||
return publicPath; | ||
} | ||
} | ||
if (dangerouslyConnectToHttpEndpointForTesting) { | ||
localTestingConfig = { | ||
endpoint: localTestingStorageEndpoint, | ||
s3BucketEndpoint: true, | ||
s3ForcePathStyle: true, | ||
}; | ||
} | ||
/** | ||
* @private | ||
*/ | ||
private _createS3(config) { | ||
const { | ||
bucket, | ||
region, | ||
credentials, | ||
dangerouslyConnectToHttpEndpointForTesting | ||
} = config; | ||
let localTestingConfig = {}; | ||
if(dangerouslyConnectToHttpEndpointForTesting) { | ||
localTestingConfig = { | ||
endpoint: localTestingStorageEndpoint, | ||
s3BucketEndpoint: true, | ||
s3ForcePathStyle : true | ||
}; | ||
} | ||
return new S3({ | ||
apiVersion: '2006-03-01', | ||
params: { Bucket: bucket }, | ||
signatureVersion: 'v4', | ||
region, | ||
credentials, | ||
...localTestingConfig | ||
}); | ||
} | ||
return new S3({ | ||
apiVersion: '2006-03-01', | ||
params: { Bucket: bucket }, | ||
signatureVersion: 'v4', | ||
region, | ||
credentials, | ||
...localTestingConfig, | ||
}); | ||
} | ||
} |
@@ -25,199 +25,213 @@ /* | ||
export default class StorageClass { | ||
/** | ||
* @private | ||
*/ | ||
private _config; | ||
private _pluggables: StorageProvider[]; | ||
/** | ||
* @private | ||
*/ | ||
private _config; | ||
private _pluggables: StorageProvider[]; | ||
/** | ||
* @public | ||
*/ | ||
public vault: StorageClass; | ||
/** | ||
* @public | ||
*/ | ||
public vault: StorageClass; | ||
/** | ||
* Initialize Storage | ||
* @param {Object} config - Configuration object for storage | ||
*/ | ||
constructor() { | ||
this._config = {}; | ||
this._pluggables = []; | ||
logger.debug('Storage Options', this._config); | ||
/** | ||
* Initialize Storage | ||
* @param {Object} config - Configuration object for storage | ||
*/ | ||
constructor() { | ||
this._config = {}; | ||
this._pluggables = []; | ||
logger.debug('Storage Options', this._config); | ||
this.get = this.get.bind(this); | ||
this.put = this.put.bind(this); | ||
this.remove = this.remove.bind(this); | ||
this.list = this.list.bind(this); | ||
} | ||
this.get = this.get.bind(this); | ||
this.put = this.put.bind(this); | ||
this.remove = this.remove.bind(this); | ||
this.list = this.list.bind(this); | ||
} | ||
public getModuleName() { | ||
return 'Storage'; | ||
} | ||
public getModuleName() { | ||
return 'Storage'; | ||
} | ||
/** | ||
* add plugin into Storage category | ||
* @param {Object} pluggable - an instance of the plugin | ||
*/ | ||
public addPluggable(pluggable: StorageProvider) { | ||
if (pluggable && pluggable.getCategory() === 'Storage') { | ||
this._pluggables.push(pluggable); | ||
let config = {}; | ||
/** | ||
* add plugin into Storage category | ||
* @param {Object} pluggable - an instance of the plugin | ||
*/ | ||
public addPluggable(pluggable: StorageProvider) { | ||
if (pluggable && pluggable.getCategory() === 'Storage') { | ||
this._pluggables.push(pluggable); | ||
let config = {}; | ||
config = pluggable.configure(this._config[pluggable.getProviderName()]); | ||
return config; | ||
} | ||
} | ||
config = pluggable.configure(this._config[pluggable.getProviderName()]); | ||
/** | ||
* Get the plugin object | ||
* @param providerName - the name of the plugin | ||
*/ | ||
public getPluggable(providerName: string) { | ||
const pluggable = this._pluggables.find(pluggable => pluggable.getProviderName() === providerName); | ||
if (pluggable === undefined) { | ||
logger.debug('No plugin found with providerName', providerName); | ||
return null; | ||
} else | ||
return pluggable; | ||
} | ||
return config; | ||
} | ||
} | ||
/** | ||
* Remove the plugin object | ||
* @param providerName - the name of the plugin | ||
*/ | ||
public removePluggable(providerName: string) { | ||
this._pluggables = this._pluggables.filter(pluggable => pluggable.getProviderName() !== providerName); | ||
return; | ||
} | ||
/** | ||
* Get the plugin object | ||
* @param providerName - the name of the plugin | ||
*/ | ||
public getPluggable(providerName: string) { | ||
const pluggable = this._pluggables.find( | ||
pluggable => pluggable.getProviderName() === providerName | ||
); | ||
if (pluggable === undefined) { | ||
logger.debug('No plugin found with providerName', providerName); | ||
return null; | ||
} else return pluggable; | ||
} | ||
/** | ||
* Configure Storage | ||
* @param {Object} config - Configuration object for storage | ||
* @return {Object} - Current configuration | ||
*/ | ||
configure(config?) { | ||
logger.debug('configure Storage'); | ||
if (!config) return this._config; | ||
/** | ||
* Remove the plugin object | ||
* @param providerName - the name of the plugin | ||
*/ | ||
public removePluggable(providerName: string) { | ||
this._pluggables = this._pluggables.filter( | ||
pluggable => pluggable.getProviderName() !== providerName | ||
); | ||
return; | ||
} | ||
const amplifyConfig = Parser.parseMobilehubConfig(config); | ||
/** | ||
* Configure Storage | ||
* @param {Object} config - Configuration object for storage | ||
* @return {Object} - Current configuration | ||
*/ | ||
configure(config?) { | ||
logger.debug('configure Storage'); | ||
if (!config) return this._config; | ||
const storageKeysFromConfig = Object.keys(amplifyConfig.Storage); | ||
const amplifyConfig = Parser.parseMobilehubConfig(config); | ||
const storageArrayKeys = [ | ||
'bucket', | ||
'region', | ||
'level', | ||
'track', | ||
'customPrefix', | ||
'serverSideEncryption', | ||
'SSECustomerAlgorithm', | ||
'SSECustomerKey', | ||
'SSECustomerKeyMD5', | ||
'SSEKMSKeyId' | ||
]; | ||
const storageKeysFromConfig = Object.keys(amplifyConfig.Storage); | ||
const isInStorageArrayKeys = (k: string) => storageArrayKeys.some(x => x === k); | ||
const checkConfigKeysFromArray = (k: string[]) => k.find(k => isInStorageArrayKeys(k)); | ||
const storageArrayKeys = [ | ||
'bucket', | ||
'region', | ||
'level', | ||
'track', | ||
'customPrefix', | ||
'serverSideEncryption', | ||
'SSECustomerAlgorithm', | ||
'SSECustomerKey', | ||
'SSECustomerKeyMD5', | ||
'SSEKMSKeyId', | ||
]; | ||
if ( | ||
storageKeysFromConfig && | ||
checkConfigKeysFromArray(storageKeysFromConfig) && | ||
!amplifyConfig.Storage[DEFAULT_PROVIDER] | ||
) { | ||
amplifyConfig.Storage[DEFAULT_PROVIDER] = {}; | ||
} | ||
const isInStorageArrayKeys = (k: string) => | ||
storageArrayKeys.some(x => x === k); | ||
const checkConfigKeysFromArray = (k: string[]) => | ||
k.find(k => isInStorageArrayKeys(k)); | ||
Object.entries(amplifyConfig.Storage).map(([key, value]) => { | ||
if (key && isInStorageArrayKeys(key) && value !== undefined) { | ||
amplifyConfig.Storage[DEFAULT_PROVIDER][key] = value; | ||
delete amplifyConfig.Storage[key]; | ||
} | ||
}); | ||
if ( | ||
storageKeysFromConfig && | ||
checkConfigKeysFromArray(storageKeysFromConfig) && | ||
!amplifyConfig.Storage[DEFAULT_PROVIDER] | ||
) { | ||
amplifyConfig.Storage[DEFAULT_PROVIDER] = {}; | ||
} | ||
// only update new values for each provider | ||
Object.keys(amplifyConfig.Storage).forEach((providerName) => { | ||
if (typeof amplifyConfig.Storage[providerName] !== 'string') { | ||
this._config[providerName] = { ...this._config[providerName], ...amplifyConfig.Storage[providerName] }; | ||
} | ||
}); | ||
Object.entries(amplifyConfig.Storage).map(([key, value]) => { | ||
if (key && isInStorageArrayKeys(key) && value !== undefined) { | ||
amplifyConfig.Storage[DEFAULT_PROVIDER][key] = value; | ||
delete amplifyConfig.Storage[key]; | ||
} | ||
}); | ||
this._pluggables.forEach((pluggable) => { | ||
pluggable.configure(this._config[pluggable.getProviderName()]); | ||
}); | ||
// only update new values for each provider | ||
Object.keys(amplifyConfig.Storage).forEach(providerName => { | ||
if (typeof amplifyConfig.Storage[providerName] !== 'string') { | ||
this._config[providerName] = { | ||
...this._config[providerName], | ||
...amplifyConfig.Storage[providerName], | ||
}; | ||
} | ||
}); | ||
if (this._pluggables.length === 0) { | ||
this.addPluggable(new AWSS3Provider()); | ||
} | ||
this._pluggables.forEach(pluggable => { | ||
pluggable.configure(this._config[pluggable.getProviderName()]); | ||
}); | ||
return this._config; | ||
} | ||
if (this._pluggables.length === 0) { | ||
this.addPluggable(new AWSS3Provider()); | ||
} | ||
/** | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to either a presigned url or the object | ||
*/ | ||
public async get(key: string, config?): Promise<String | Object> { | ||
return this._config; | ||
} | ||
const { provider = DEFAULT_PROVIDER } = config || {}; | ||
const prov = this._pluggables.find(pluggable => pluggable.getProviderName() === provider); | ||
if (prov === undefined) { | ||
logger.debug('No plugin found with providerName', provider); | ||
Promise.reject('No plugin found in Storage for the provider'); | ||
} | ||
return prov.get(key, config); | ||
} | ||
/** | ||
* Get a presigned URL of the file or the object data when download:true | ||
* | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public, download: true|false } | ||
* @return - A promise resolves to either a presigned url or the object | ||
*/ | ||
public async get(key: string, config?): Promise<String | Object> { | ||
const { provider = DEFAULT_PROVIDER } = config || {}; | ||
const prov = this._pluggables.find( | ||
pluggable => pluggable.getProviderName() === provider | ||
); | ||
if (prov === undefined) { | ||
logger.debug('No plugin found with providerName', provider); | ||
Promise.reject('No plugin found in Storage for the provider'); | ||
} | ||
return prov.get(key, config); | ||
} | ||
/** | ||
* Put a file in storage bucket specified to configure method | ||
* @param {String} key - key of the object | ||
* @param {Object} object - File to be put in bucket | ||
* @param {Object} [config] - { level : private|protected|public, contentType: MIME Types, | ||
* progressCallback: function } | ||
* @return - promise resolves to object on success | ||
*/ | ||
public async put(key: string, object, config?): Promise<Object> { | ||
const { provider = DEFAULT_PROVIDER } = config || {}; | ||
const prov = this._pluggables.find(pluggable => pluggable.getProviderName() === provider); | ||
if (prov === undefined) { | ||
logger.debug('No plugin found with providerName', provider); | ||
Promise.reject('No plugin found in Storage for the provider'); | ||
} | ||
return prov.put(key, object, config); | ||
} | ||
/** | ||
* Put a file in storage bucket specified to configure method | ||
* @param {String} key - key of the object | ||
* @param {Object} object - File to be put in bucket | ||
* @param {Object} [config] - { level : private|protected|public, contentType: MIME Types, | ||
* progressCallback: function } | ||
* @return - promise resolves to object on success | ||
*/ | ||
public async put(key: string, object, config?): Promise<Object> { | ||
const { provider = DEFAULT_PROVIDER } = config || {}; | ||
const prov = this._pluggables.find( | ||
pluggable => pluggable.getProviderName() === provider | ||
); | ||
if (prov === undefined) { | ||
logger.debug('No plugin found with providerName', provider); | ||
Promise.reject('No plugin found in Storage for the provider'); | ||
} | ||
return prov.put(key, object, config); | ||
} | ||
/** | ||
* Remove the object for specified key | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public } | ||
* @return - Promise resolves upon successful removal of the object | ||
*/ | ||
public async remove(key: string, config?): Promise<any> { | ||
const { provider = DEFAULT_PROVIDER } = config || {}; | ||
const prov = this._pluggables.find(pluggable => pluggable.getProviderName() === provider); | ||
if (prov === undefined) { | ||
logger.debug('No plugin found with providerName', provider); | ||
Promise.reject('No plugin found in Storage for the provider'); | ||
} | ||
return prov.remove(key, config); | ||
} | ||
/** | ||
* Remove the object for specified key | ||
* @param {String} key - key of the object | ||
* @param {Object} [config] - { level : private|protected|public } | ||
* @return - Promise resolves upon successful removal of the object | ||
*/ | ||
public async remove(key: string, config?): Promise<any> { | ||
const { provider = DEFAULT_PROVIDER } = config || {}; | ||
const prov = this._pluggables.find( | ||
pluggable => pluggable.getProviderName() === provider | ||
); | ||
if (prov === undefined) { | ||
logger.debug('No plugin found with providerName', provider); | ||
Promise.reject('No plugin found in Storage for the provider'); | ||
} | ||
return prov.remove(key, config); | ||
} | ||
/** | ||
* List bucket objects relative to the level and prefix specified | ||
* @param {String} path - the path that contains objects | ||
* @param {Object} [config] - { level : private|protected|public } | ||
* @return - Promise resolves to list of keys for all objects in path | ||
*/ | ||
public async list(path, config?): Promise<any> { | ||
const { provider = DEFAULT_PROVIDER } = config || {}; | ||
const prov = this._pluggables.find(pluggable => pluggable.getProviderName() === provider); | ||
if (prov === undefined) { | ||
logger.debug('No plugin found with providerName', provider); | ||
Promise.reject('No plugin found in Storage for the provider'); | ||
} | ||
return prov.list(path, config); | ||
} | ||
/** | ||
* List bucket objects relative to the level and prefix specified | ||
* @param {String} path - the path that contains objects | ||
* @param {Object} [config] - { level : private|protected|public } | ||
* @return - Promise resolves to list of keys for all objects in path | ||
*/ | ||
public async list(path, config?): Promise<any> { | ||
const { provider = DEFAULT_PROVIDER } = config || {}; | ||
const prov = this._pluggables.find( | ||
pluggable => pluggable.getProviderName() === provider | ||
); | ||
if (prov === undefined) { | ||
logger.debug('No plugin found with providerName', provider); | ||
Promise.reject('No plugin found in Storage for the provider'); | ||
} | ||
return prov.list(path, config); | ||
} | ||
} |
@@ -14,24 +14,24 @@ /* | ||
export interface StorageProvider { | ||
// you need to implement those methods | ||
// configure your provider | ||
configure(config: object): object; | ||
// you need to implement those methods | ||
// get object/pre-signed url from storage | ||
get(key: string, options?): Promise<String|Object> | ||
// configure your provider | ||
configure(config: object): object; | ||
// upload storage object | ||
put(key: string, object, options?): Promise<Object> | ||
// get object/pre-signed url from storage | ||
get(key: string, options?): Promise<String | Object>; | ||
// remove object | ||
remove(key: string, options?): Promise<any> | ||
// upload storage object | ||
put(key: string, object, options?): Promise<Object>; | ||
// list objects for the path | ||
list(path, options?): Promise<any> | ||
// return 'Storage'; | ||
getCategory(): string; | ||
// return the name of you provider | ||
getProviderName(): string; | ||
// remove object | ||
remove(key: string, options?): Promise<any>; | ||
// list objects for the path | ||
list(path, options?): Promise<any>; | ||
// return 'Storage'; | ||
getCategory(): string; | ||
// return the name of you provider | ||
getProviderName(): string; | ||
} |
@@ -17,6 +17,6 @@ /* | ||
export interface StorageOptions { | ||
bucket?: string; | ||
region?: string; | ||
level?: string; | ||
credentials?: object; | ||
bucket?: string; | ||
region?: string; | ||
level?: string; | ||
credentials?: object; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
25483
4960454