twome
twome

Reputation: 35

read file from s3 bucket

I'm trying to get a file from s3 bucket with golang. What's special in my request is that I need to get a file from the root of the s3. i.e, in my situation, i have a buckets folder which is the root for the s3, inside that i have folders and files. I need to get the files from the buckets folder. it means that i don't have a bucket folder because i access only to the root. the code im trying is:

numBytes, err := downloader.Download(file, &s3.GetObjectInput{
  Bucket: aws.String("/"),
  Key:   aws.String("some_image.jpeg"),
})

The problem is I got an error that says the object does not exist. Is it possible to read files from the root of s3? What do I need to write in the bucket? the key is written okay?

Many thanks for helping!

Upvotes: 0

Views: 1190

Answers (1)

Chris
Chris

Reputation: 388

All files in S3 are stored inside buckets. You're not able to store a file in the root of s3.

Each bucket is its own distinct namespace. You can have multiple buckets in your Amazon account, and each file must belong to one of those buckets.

You can either create a bucket using the AWS web interface, command line tools or API. (Or 3rd party software like Cyberduck).

You can read more about buckets in S3 here: https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingBucket.html

Upvotes: 1

Related Questions