aws Verified current stable Not installed? Cloud Infrastructure

Aws / Download Object From Bucket

Download Object From Bucket

Downloads an object from a specified S3 bucket to a local path.

$
Terminal
aws s3api get-object --bucket <bucket_name> --key <object_key> <path/to/output_file>

When To Use

When retrieving files for analysis or processing from S3.

Pro Tip

Use version IDs to specify particular object versions when versioning is enabled.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
aws s3api get-object --bucket <bucket_name> --key <object_key> <path/to/output_file>

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
Downloading s3://my-bucket/my-object.txt to my-local-file.txt

Completed 512 bytes of 512 bytes (16.2 KiB/s) with 1 file(s) remaining

Anatomy of Output

Understanding the result

Downloading 'unique-bucket-name/file-name.txt'... Download Status

Indicates the start of the download process.

Download complete: 'path/to/local/output.txt' saved. Completion Status

Confirms successful download of the object.

Object size: 2048 bytes Downloaded Size

Size of the downloaded object.

Troubleshooting

Common pitfalls

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

Solution: Check the bucket name for typos.

An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist

Solution: Verify the object key exists in the specified bucket.

An error occurred (InvalidRequest) when calling the GetObject operation: The request is not valid

Solution: Ensure that the object you are trying to download is not marked as deleted.

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/output_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.

How To Run

Execution path

  1. Step 1

    Run: aws s3api get-object --bucket my-bucket --key my-object.txt my-local-file.txt

  2. Step 2

    Check for the existence of my-local-file.txt using: ls -lh my-local-file.txt

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.