I have uploaded an image to Amazon S3 storage. But how can I access this image by url? I have made the folder and file public but still get AccessDenied error if try to access it by url https://s3.amazonaws.com/bucket/path/image.png
18 Answers
This is an older question, but for anybody who comes across this question, once I made the file public I was able to access my image as https://mybucket.s3.amazonaws.com/myfolder/afile.jpg

- 3,885
- 1
- 33
- 44
-
22yet when I click on it, it gives me access denied error? – Kick Buttowski Aug 11 '18 at 22:47
-
6@KickButtowski You have to replace mybucket in the url with the bucket name which is actually present. – Siddharth Sachdeva Sep 17 '18 at 12:36
-
It's not accessible still – Pulasthi Aberathne Jul 12 '23 at 09:15
-
@PulasthiAberathne you have to make your bucket public, there's a lot of set up you have to do for that, find a video that walks you through it – Soccerball123 Jul 14 '23 at 19:34
-
@Soccerball123 yea we have to change the policies in here. I managed to configure that manually – Pulasthi Aberathne Jul 15 '23 at 20:14
in my case i have uploaded image privately so that i was unable to access. i did following code
const AWS = require('aws-sdk')
const myBucket = 'BUCKET_NAME'
const myKey = 'FILE_NAME.JPG'
const signedUrlExpireSeconds = 60 * 1
const s3 = new AWS.S3({
accessKeyId: "ACCESS_KEY_ID",
signatureVersion: 'v4',
region: 'S3_REGION',
secretAccessKey: "ACCESS_SECRET"
});
const url = s3.getSignedUrl('getObject', {
Bucket: myBucket,
Key: myKey,
Expires: signedUrlExpireSeconds
})
console.log(url)

- 2,232
- 22
- 21
-
1Thank you for this answer! This was the easiest way of solving my problem without making everything public! – alexcodes Dec 06 '20 at 19:53
-
Im trying to find some good documentation to learn how to upload an image to S3, the aws official documentation feels very cryptic, any tips? This answer alone is a very useful example to get a URL, but im looking for good examples to upload an image from my node app – xunux Feb 26 '21 at 03:46
-
1
You can access your image by using:
https://s3.amazonaws.com/bucketname/foldername/imagename.jpg
or if there are no folders, you can do:
https://s3.amazonaws.com/bucketname/imagename.jpg
upvote if helps. It conforms to present AWS dated 30 may 2017.

- 387
- 4
- 18
-
3I thin' this no longer works: `the bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint` – pmiranda Jan 20 '21 at 19:20
One of easiest way is to make a bucket policy.
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "MakeItPublic",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::yourbucketname.com/*"
}]
}

- 1,107
- 2
- 8
- 26

- 115
- 1
- 7
-
-
here is how to set public bucket policy on minio using awscli https://github.com/minio/minio/issues/1508#issuecomment-449843076 – srghma Dec 25 '18 at 11:42
Seems like you can now simply right-click on any folder inside a bucket and select 'Make Public' to make everything in that folder public. It may not work at the bucket level itself.

- 5,691
- 2
- 28
- 31
-
This is great if you're trying to set all existing files to public. As you upload files, they apparently don't get this "public" status. If adding the object via an API, you can set that "public" access at the time of upload - http://stackoverflow.com/questions/10055016/how-to-mark-a-certain-s3-file-as-make-public – Mattiavelli Sep 23 '16 at 21:48
For future reference, if you want to access a file in Amazon S3 the URL needs to be something like:
bucketname.s3.region.amazonaws.com/foldername/image.png
Example: my-awesome-bucket.s3.eu-central-1.amazonaws.com/media/img/dog.png
Don't forget to set the object to public.
Inside S3 if you click on the object will you see a field called: Object URL. That's the object's web address.

- 193
- 1
- 12
-
Hi Jaoa. I've downvoted this answer because I don't think it adds any new information - this question is almost a decade old and there are already several answers (including the accepted answer) that are similar to this one. Please review and consider deleting this answer if appropriate. – Captain Hat Jan 23 '21 at 01:58
-
Hello @CaptainHat! At least for me, the accepted answer didn't work. And the reason was that the link is different. This could be because S3 updated its link URL. I thought to post a comment, in case someone had the same issue. – Joao Antunes Jan 23 '21 at 14:12
-
Oh okay. Thanks for clarifying. Consider posting this content as a comment on the relevant answer? I'll leave it to your judgement. – Captain Hat Jan 23 '21 at 14:13
-
Unfortunately, I only have 41 reputation points. Stackoverflow only allows you to comment on other people's answers when you have 50+ :( – Joao Antunes Jan 23 '21 at 14:20
make sure you access image using the same case as it was uploaded and stored on S3. for example, if you uploaded image_name.JPG, you should use the same name, but not image_name.jpg

- 1,402
- 1
- 14
- 22
On your console, right click on the image you want to access and click on "Make Public"; when thats done right click on the image again and click on "Properties" and copy the Link from the Extended view.

- 64
- 5
I came across this question whilst looking for a solution to a similar problem with being unable to access images.
It turns out that images with a %
in their filename, when being accessed, must have the %
symbol URL encoded to %25
.
i.e. photo%20of%20a%20banana%20-%2019%20june%202016.jpg
needs to be accessed via photo%2520of%2520a%2520banana%2520-%252019%2520june%25202016.jpg
.
However, URL encoding the full path didn't work for us, since the slashes, etc would be encoded, and the path would not work. In our specific case, simply replacing %
with %25
in all access paths made the difference.

- 2,542
- 4
- 36
- 42
I was having the same problem. I have the issue the spacing in image url. I did this to make it work:
String imgUrl=prizes.get(position).getImagePreview().replaceAll("\\s","%20");
now pass this url to picasso:
Picasso.with(mContext)
.load(imgUrl)
.into(mImageView);

- 2,531
- 1
- 29
- 42
To access private images via URL you must provide Query-string authentication. Query-string authentication version 4 requires the X-Amz-Algorithm, X-Amz-Credential, X-Amz-Signature, X-Amz-Date, X-Amz-SignedHeaders, and X-Amz-Expires parameters.

- 2,606
- 1
- 17
- 26
Just addon to @akotian answer, you can get the object URL by clicking the object as follows
and to access publically you can set the ACL programmatically while uploading the object to the bucket
i.e sample java request
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
.contentType(contentType)
.bucket(LOGO_BUCKET_NAME)
.key(LOGO_FOLDER_PREFIX+fileName)
.acl(ObjectCannedACL.PUBLIC_READ)// this make public read
.metadata(metadata)
.build();

- 347
- 3
- 11
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:GetObjectVersion"
],
"Resource": [
"arn:aws:s3:::DOC-EXAMPLE-BUCKET/*"
]
}
]
}
use this policy for that bucket, which makes it public.

- 1
- 1
Adding bucket policy worked for me
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::yourbucketname/*"
}
]
}

- 431
- 5
- 9
Turn off Block public access (bucket settings) from Permissions tab inside your bucket. You also need to Edit the permissions of the object. Provide Read access on Grantee Everyone (public access). Then chech "I understand the effects of these changes on this object." and Save changes.

- 617
- 1
- 6
- 12
Try to access by :
https://s3.amazonaws.com//file.format
or go to the file and click "open" so it will redirect you the right path
Change your Bucket.. It may works