

 AWS Cloud9 is no longer available to new customers. Existing customers of AWS Cloud9 can continue to use the service as normal. [Learn more](https://aws.amazon.com/blogs/devops/how-to-migrate-from-aws-cloud9-to-aws-ide-toolkits-or-aws-cloudshell/)

# Working with Amazon S3 using AWS Toolkit
<a name="s3-toolkit"></a>

The following topics describe how to use the AWS Toolkit to work with [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/) buckets and objects in an AWS account.

**Topics**
+ [Working with Amazon S3 buckets](work-with-S3-buckets.md)
+ [Working with Amazon S3 objects](work-with-S3-objects.md)

# Working with Amazon S3 buckets
<a name="work-with-S3-buckets"></a>

Every object you store in Amazon S3 resides in a bucket. You can use buckets to group related objects in the same way that you use a directory to group files in a file system.

**Topics**
+ [Creating an Amazon S3 bucket](#creating-s3-bucket)
+ [Adding a folder to an Amazon S3 bucket](#adding-folders)
+ [Deleting an Amazon S3 bucket](#deleting-s3-buckets)
+ [Configuring the display of Amazon S3 items](#configuring-items-display)

## Creating an Amazon S3 bucket
<a name="creating-s3-bucket"></a>

1. In the **AWS Explorer**, open the context (right-click) menu for the **S3** node, and then choose **Create Bucket**. 

1. In the **Bucket Name** field, enter a valid name for the bucket. Press **Enter** to confirm.

   The new bucket is displayed under the **S3** node.
**Note**  
Because your S3 bucket can be used as a URL that's accessed publicly, the bucket name that you choose must be globally unique. If some other account has already created a bucket with the name that you chose, you must use another name.  
If you can't create a bucket, you can check the **AWS Toolkit Logs** in the **Output** tab. For example, if you use a bucket name already in use, a `BucketAlreadyExists` error occurs. For more information, see [Bucket restrictions and limitations](https://docs.aws.amazon.com/AmazonS3/latest/userguide/BucketRestrictions.html) in the *Amazon Simple Storage Service User Guide*.

   After a bucket is created, you can copy its name and Amazon Resource Name (ARN) to the clipboard. Open the context (right-click) menu for the bucket entry and select the relevant option from the menu.

## Adding a folder to an Amazon S3 bucket
<a name="adding-folders"></a>

You organize a bucket's contents by grouping objects in folders. You can also create folders within other folders.

1. In the **AWS Explorer**, choose the **S3** node to view the list of buckets.

1. Open the context (right-click) menu for a bucket or a folder, and then choose **Create Folder**. 

1. Enter a **Folder Name**, and then press **Enter**.

   The new folder is now displayed below the selected bucket and folder in the **AWS Explorer** window.

## Deleting an Amazon S3 bucket
<a name="deleting-s3-buckets"></a>

When you delete a bucket, you also delete the folders and objects that it contains. Before the bucket is deleted, you're asked to confirm that you want to do this.

**Note**  
[To delete only a folder](https://docs.aws.amazon.com/AmazonS3/latest/userguide/delete-folders.html), not the entire bucket, use the AWS Management Console. 

1. In the **AWS Explorer**, choose the **S3** node to expand the list of buckets.

1. Open the context menu for the bucket to delete, and then choose **Delete**.

1. Enter the bucket's name to confirm that you want to delete it, and then press **Enter**.
**Note**  
If the bucket contains objects, the bucket is emptied before you delete it. This can take some time if it's necessary to delete every version of thousands of objects. A notification is displayed after the delete process is complete.

## Configuring the display of Amazon S3 items
<a name="configuring-items-display"></a>

If you're working with a large number of Amazon S3 objects or folders, it's helpful to specify how many are displayed at one time. When the maximum number is displayed, you can choose **Load More** to display the next batch. 

1. On the menu bar, choose **AWS Cloud9**, **Preferences**.

1. In the **Preferences** window, expand **Project Settings**, and go to the **EXTENSIONS** section to choose **AWS Configuration**.

1. In the **AWS Configuration** pane, go to the **AWS > S3: Max Items Per Page** setting.

1. Before choosing to load more, change the default value to the number of S3 items that you want displayed.
**Note**  
The range of accepted values is between 3 and 1000. This setting applies only to the number of objects or folders displayed at one time. All the buckets that you created are displayed at once. By default, you can create up to 100 buckets in each of your AWS accounts.

# Working with Amazon S3 objects
<a name="work-with-S3-objects"></a>

Objects are the fundamental entities stored in Amazon S3. Objects consist of object data and metadata.

**Topics**
+ [Uploading a file to an Amazon S3 bucket](#uploading-s3-object-to-bucket)
+ [Downloading an Amazon S3 object](#downloading-s3-object)
+ [Deleting an Amazon S3 object](#deleting-s3-object)
+ [Generating a presigned URL for an Amazon S3 object](#presigned-s3-object)

## Uploading a file to an Amazon S3 bucket
<a name="uploading-s3-object-to-bucket"></a>

You can use the Toolkit interface or a command to upload a file to a bucket 

Both methods allow you to upload a file from a user's environment and store it as an S3 object in the AWS Cloud. You can upload a file to a bucket or to a folder that organizes that bucket's contents.

## Upload a file to an S3 bucket using the interface


1. In the **AWS Explorer**, choose the **S3** node to view the list of buckets.

1. Open the context menu (right-click) for a bucket or a folder in that bucket, and then choose **Upload File**. 
**Note**  
If you open the context menu (right-click) an S3 object, you can choose **Upload to Parent**. This enables you to add a file to the folder or bucket that contains the selected file.

1. Using your environment's file manager, select a file, and then choose **Upload**.

   The selected file is uploaded as an S3 object to the bucket or folder. Each object's entry describes the size of the stored object and how long ago it was uploaded. You can pause over the object's listing to view the path, size, and time when it was last modified.

## Upload the current file to an S3 bucket using a command


1. To select a file for upload, choose the file's tab.

1. Press **Ctrl\$1P** to display the **Commands** pane.

1. For **Go To Anything**, start to enter the phrase `upload file` to display the `AWS: Upload File` command. Choose the command when it appears.

1. For **Step 1: Select a file to upload**, you can choose the file you've selected or browse for another file.

1. For **Step 2: Select an S3 bucket to upload to**, choose a bucket from the list.

   The selected file is uploaded as an S3 object to the bucket or folder. Each object's entry describes the size of the stored object and how long ago it was uploaded. You can pause over the object's listing to view the path, size, and time when it was last modified.

## Downloading an Amazon S3 object
<a name="downloading-s3-object"></a>

You can download objects in an Amazon S3 bucket from the AWS Cloud to a folder in your AWS Cloud9 environment.

1. In the **AWS Explorer**, choose the **S3** node to view the list of buckets.

1. In a bucket or in a folder in a bucket, open the context menu (right-click) for an object, and then choose **Download As**.

1. Using your environment's file manager, select a destination folder, enter a file name, and then choose **Download**.

After a file is downloaded, you can open it in AWS Cloud9.

## Deleting an Amazon S3 object
<a name="deleting-s3-object"></a>

You can permanently delete an object if it's in a non-versioned bucket. But for versioning-enabled buckets, a delete request does not permanently delete that object. Instead, Amazon S3 inserts a delete marker in the bucket. For more information, see [Deleting object versions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/DeletingObjectVersions.html) in the *Amazon Simple Storage Service User Guide*.

1. In the **AWS Explorer**, choose the **S3** node to view the list of buckets.

1. In a bucket or a folder in a bucket, open the context menu (right-click) for an object, and then choose **Delete**.

1. Choose **Delete** to confirm the deletion.

## Generating a presigned URL for an Amazon S3 object
<a name="presigned-s3-object"></a>

With presigned URLS, an object owner can share private Amazon S3 objects with others by granting time-limited permission to download the objects. For more information, see [Sharing an object with a presigned URL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/ShareObjectPreSignedURL.html) in the *Amazon S3 User Guide*.

1. In the **AWS Explorer**, choose the **S3** node to view the list of buckets.

1. In a bucket or a folder in a bucket, right-click an object, and then choose **Generate Presigned URL**.

1. In the AWS Toolkit command pane, enter the number of minutes that the URL can be used to access the object. Press **Enter** to confirm.

   The status at the bottom of the IDE confirms that presigned URL for the object was copied to your clipboard.