user2636197
user2636197

Reputation: 4122

Amazon S3 hardcode my bucket URL

I am using Amazon S3 to store images for my web app and iOS app.

I wonder if I can safely hardcode my bucket URL when fetching the images? So that I don't have to make one more API call just to fetch my URL.

For example, hardcoding this in my apps code:

https://s3.eu-central-1.amazonaws.com/mybucket/images/{some_var}

Upvotes: 6

Views: 1228

Answers (2)

Chandan Nayak
Chandan Nayak

Reputation: 10917

Just to add - you can do it in two ways

  1. Virtual-hosted–style URL (Bucket name is part of the domain name in the URL)
    • http://bucket-name.s3.amazonaws.com/<file-name>
    • http://bucket-name.s3-aws-region.amazonaws.com/<file-name>
  2. Path-style URL (Bucket name is not part of the domain and endpoint you use must match the region in which the bucket resides[except N. Virginia])
    • http://region-name.amazonaws.com/bucket-name/<file-name>

Detail Read:
http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html

Upvotes: 0

cjwfuller
cjwfuller

Reputation: 450

Yes should be safe.

If this did change then it would break.. so much. AWS service name, region, domain are unlikely to change. The other parts of the URL are under your control.

Upvotes: 3

Related Questions