From d3b586b7fba38d5aecdfd2aa4274f5a2de1810bd Mon Sep 17 00:00:00 2001 From: Chris Eich Date: Tue, 10 Apr 2018 17:22:18 -0700 Subject: [PATCH] add docs for protected storage level --- docs/_config.yml | 2 +- docs/media/examples.md | 4 ++-- docs/media/storage_guide.md | 8 +++++--- packages/aws-amplify/src/Storage/Storage.ts | 8 ++++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index 2bcadf8c688..1d38eeeebae 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -161,7 +161,7 @@ category_list: - title: AWS Pinpoint url: https://aws.amazon.com/pinpoint/ - title: Storage - excerpt: A simple mechanism for managing user content in public or private storage. + excerpt: A simple mechanism for managing user content in public, protected or private storage. cta: Read more class: aws-icon-ps-60-file-box url: '/media/storage_guide' diff --git a/docs/media/examples.md b/docs/media/examples.md index 9c05696b0f2..f281b3c5aa8 100644 --- a/docs/media/examples.md +++ b/docs/media/examples.md @@ -77,13 +77,13 @@ For a complete guide for starting your app with AWS Amplify, please see our [Qui ### Store Files on The Cloud -AWS Amplify's default implementation for Storage category uses Amazon S3. You can store content in public or private Amazon S3 buckets. Private folders enable the resources are only available to a specific user identity. +AWS Amplify's default implementation for Storage category uses Amazon S3. You can store content in public, protected or private folders. Protected folders allow content to be readable by everyone, but writable only by the creating user. Private folders restrict all content access to the creating user. ```js Storage.put(key, fileObj, {level: 'private'}) .then (result => console.log(result)) .catch(err => console.log(err)); - + // Stores data with specifying its MIME type Storage.put(key, fileObj, { level: 'private', diff --git a/docs/media/storage_guide.md b/docs/media/storage_guide.md index 2ed88c6667a..4e46933d546 100644 --- a/docs/media/storage_guide.md +++ b/docs/media/storage_guide.md @@ -3,7 +3,7 @@ # Storage -AWS Amplify Storage module provides a simple mechanism for managing user content for your app in public or private storage buckets. +AWS Amplify Storage module provides a simple mechanism for managing user content for your app in public, protected or private storage buckets. ## Installation and Configuration @@ -89,13 +89,15 @@ Note: You can restrict the access to your bucket by updating AllowedOrigin to in ### File Access Levels -Storage module can manage files in two different access levels; `public` and `private`. +Storage module can manage files with three different access levels; `public`, `protected` and `private`. Files with public access level can be accessed by all users who are using your app. In S3, they are stored under the `public/` path in your S3 bucket. +Files with protected access level are readable by all users but writable only by the creating user. In S3, they are stored under `protected/{user_identity_id}/` where the **user_identity_id** corresponds to a unique Amazon Cognito Identity ID for that user. + Files with private access level are only accessible for specific authenticated users only. In S3, they are stored under `private/{user_identity_id}/` where the **user_identity_id** corresponds to a unique Amazon Cognito Identity ID for that user. -The access level can be configured on the Storage object globally. Alternatively, the access levels can be set in individual function calls. +The access level can be configured on the Storage object globally. Alternatively, the access levels can be set in individual function calls. Default access level for Storage module is `public`. Unless you configure Storage otherwise, all uploaded files will be publicly available for all users. {: .callout .callout--info} diff --git a/packages/aws-amplify/src/Storage/Storage.ts b/packages/aws-amplify/src/Storage/Storage.ts index a5af2a4509f..0e44da2391f 100644 --- a/packages/aws-amplify/src/Storage/Storage.ts +++ b/packages/aws-amplify/src/Storage/Storage.ts @@ -76,7 +76,7 @@ export default class StorageClass { /** * Get a presigned URL of the file * @param {String} key - key of the object - * @param {Object} [options] - { level : private|public } + * @param {Object} [options] - { level : private|protected|public } * @return - A promise resolves to Amazon S3 presigned URL on success */ public async get(key: string, options?): Promise { @@ -141,7 +141,7 @@ export default class StorageClass { * Put a file in S3 bucket specified to configure method * @param {Stirng} key - key of the object * @param {Object} object - File to be put in Amazon S3 bucket - * @param {Object} [options] - { level : private|public, contentType: MIME Types } + * @param {Object} [options] - { level : private|protected|public, contentType: MIME Types } * @return - promise resolves to object on success */ public async put(key: string, object, options?): Promise { @@ -195,7 +195,7 @@ export default class StorageClass { /** * Remove the object for specified key * @param {String} key - key of the object - * @param {Object} [options] - { level : private|public } + * @param {Object} [options] - { level : private|protected|public } * @return - Promise resolves upon successful removal of the object */ public async remove(key: string, options?): Promise { @@ -237,7 +237,7 @@ export default class StorageClass { /** * List bucket objects relative to the level and prefix specified * @param {String} path - the path that contains objects - * @param {Object} [options] - { level : private|public } + * @param {Object} [options] - { level : private|protected|public } * @return - Promise resolves to list of keys for all objects in path */ public async list(path, options?): Promise {