aws Verified current stable Not installed? Cloud Infrastructure

Aws / Add Object To Bucket

Add Object To Bucket

Uploads an object to a specified S3 bucket from a local file path.

$
Terminal
aws s3api put-object --bucket <bucket_name> --key <object_key> --body <path/to/file>

When To Use

When transferring files to S3 for storage or processing.

Pro Tip

Be mindful of S3 object limits; multipart uploads may be required for files exceeding 5 GB.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
aws s3api put-object --bucket <bucket_name> --key <object_key> --body <path/to/file>

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
{\n  "ETag": "\"fba541fce87290d8b10bc1f2b65e5064\"",\n  "ResponseMetadata": {\n    "RequestId": "123ABC456DEF",\n    "HostId": "XYZ123+abc/def+ghi",\n    "HTTPStatusCode": 200,\n    "HTTPHeaders": {\n      "content-length": "0",\n      "date": "Mon, 01 Jan 2023 12:00:00 GMT",\n      "x-amz-request-id": "123ABC456DEF"\n    }\n  }\n}

Anatomy of Output

Understanding the result

Uploading 'path/to/local/file.txt' to bucket 'unique-bucket-name'... Upload Status

Indicates the start of the upload process.

Upload complete: 'unique-bucket-name/file-name.txt' Completion Status

Confirms successful upload of the object.

Object size: 2048 bytes Object Size

Size of the uploaded object.

Troubleshooting

Common pitfalls

An error occurred (NoSuchBucket) when calling the PutObject operation: The specified bucket does not exist

Solution: Ensure the bucket name is correct and exists.

An error occurred (InvalidPart) when calling the PutObject operation: The specified part does not exist

Solution: Confirm that multipart upload parts are correctly specified.

An error occurred (EntityTooLarge) when calling the PutObject operation: The request entity is too large

Solution: Consider using multipart upload for files larger than 5 GB.

Command Breakdown

What each part is doing

aws
Base Command
The executable that performs this operation. Here it runs Aws before the shell applies any redirect operators.
<bucket_name>
bucket name
The value supplied for bucket name.
<object_key>
object key
The value supplied for object key.
<path/to/file>
Input Files
The file path or paths supplied to this command.
--bucket
Command Option
Tool-specific option used by this command invocation.
--key
Command Option
Tool-specific option used by this command invocation.
--body
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Run the command: aws s3api put-object --bucket my-bucket --key my-object.txt --body /path/to/file.txt

  2. Step 2

    Verify the object addition with: aws s3api list-objects --bucket my-bucket

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.