Open In App

How to Get Object in AWS S3 Using UI & CLI ?

The Amazon Web Services (AWS) Simple Storage Service (S3) is a scalable object storage service that allows you to store and retrieve any amount of data at any time. The AWS SDK for JavaScript in Node.js provides the getObject method, which can be used to download objects from S3.

This article will show you how to deploy “getObject:aws s3” through the AWS Management Console and AWS CLI. Additionally, this article will discuss how to retrieve the object when it is stored under different storage classes.



Terminologies used in AWS S3

Step-by-Step Process AWS S3 Get Object

Using AWS Management Console

Step 1: Access the AWS Management Console



Step 2: Navigate To Amazon S3

Step 3: Choose Bucket and Object

Step 4: Get Object

Alternatively from the objects details page, one may also look at its metadata, permissions while managing versions among other aspects.

Using AWS CLI

Follow the AWS CLI installation instructions available at Install the latest version of the AWS CLI.

Step 1: Configure the AWS CLI

Step 2: Retrieve Object

Below are some commonly used parameters:

Downloading From S3

"aws s3api get-object --bucket  Bucket_name  --key  Keypath  Local path"

This command downloads the object specified by key in YOUR_BUCKET bucket to path/to/local on your local machine.

Downloading Specific Version Of an Object

"aws s3api get-object --bucket   Bucket_name  --key  Keypath  --version-id  version_id Local path "

Change version_id into the actual version ID for downloading a particular copy.

Download a Specific Range of Bytes

"aws s3api get-object --bucket  Bucket_name --key KeyPath --range bytes=20-30 LocalPath"

A helpful utility to download only part of large files or in other words partial downloads, is this command that downloads bytes 20-30 of object.

Get Recently Modified File

"aws s3api get-object --bucket  Bucket_name --key KeyPath --if-modified-since 2024-04-08 LocalPath"

This command downloads the object but only when it has been changed after April 8, 2024.

AWS S3 Get Object – FAQ’s

What is a single command I can use to download multiple S3 objects using AWS CLI?

The sync command can be used for downloading multiple objects:

aws s3 sync s3://my-bucket/ /path/to/local/directory

Can I use getObject() API to retrieve my object?

Yes, by specifying an object version ID you may obtain any specific version of your choice:

aws s3api get-object --bucket my-bucket --key my-file.txt --version-id my-version-id /path/to/local/file.txt

How do I set permissions when downloading a file with AWS CLI?

Permissions can be set when retrieving an object using aws cli by using –acl option. For example, let’s make this thing public.

aws s3 cp s3://my-bucket/my-file.txt /path/to/local/file.txt --acl public-read

Can I access files stored in another person’s AWS Account via getObject() method?

No, This way only allows retrieving an object that is in an S3 bucket which belongs to you.

Can I use getObject to retrieve objects larger than 5GB in size?

Yes, there is no limit on size for GET requests made through curl or aws-cli. The Amazon S3 Transfer Acceleration mechanism handles large files by automatically dividing them into smaller parts and rebuilding them on our end during retrieval.


Article Tags :