Skip to content

Uploading Objects to S3

This guide explains how to upload files (or “objects”) to your Amazon S3 bucket. You will learn how to use the AWS Command Line Interface (CLI) to upload files, which is a common and efficient method for managing your S3 resources.

Before you begin, you will need:

  • An active University of Oregon AWS account.
  • An existing S3 bucket. You can create one by following our Using Amazon S3 for Object Storage guide.
  • The AWS CLI installed and configured with your UO account credentials.

The AWS CLI provides a simple command, aws s3 cp, to copy files to and from S3. It works much like the cp command on Linux or macOS.

To upload a single file to your S3 bucket, use the following command. Replace my-local-file.txt with the path to your local file and s3://your-bucket-name with the URI of your S3 bucket.

Terminal window
aws s3 cp my-local-file.txt s3://your-bucket-name/

To upload an entire directory, you can use the --recursive flag. This will copy all files and subdirectories from the local path to the S3 bucket.

Terminal window
aws s3 cp ./my-local-directory/ s3://your-bucket-name/ --recursive
  • aws s3 cp: This is the AWS CLI command for copying objects to, from, and between S3 buckets.
  • my-local-file.txt: This is the path to the local file you want to upload.
  • s3://your-bucket-name/: This is the destination S3 bucket URI. The s3:// prefix is required.
  • --recursive: This flag is used to copy an entire directory and its contents.

Now that you know how to upload objects to S3, you can start using it to store your data. Here are some next steps you might consider: