# Access Denied for aws S3 image

**URL:** https://meta.discourse.org/t/access-denied-for-aws-s3-image/98218
**Category:** Bug
**Created:** [September 27, 2018, 4:02pm UTC](https://meta.discourse.org/t/access-denied-for-aws-s3-image/98218 "2018-09-27T16:02:51Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Pravi](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@Pravi](https://meta.discourse.org/u/Pravi)
#### Post date: [September 27, 2018, 4:02pm UTC](https://meta.discourse.org/t/access-denied-for-aws-s3-image/98218/1 "2018-09-27T16:02:51Z")

</div>

Hello guys,  
I uploaded an image using the upload option in the customise theme section. Two minutes later, I removed the image and uploaded the same image with a new name. Surprisingly, the newly uploaded image picked up the name of the previously uploaded image. Is that a bug ??

 ![theme](https://global.discourse-cdn.com/meta/original/3X/7/b/7be508232ba940cb460a0cd368a1cf478e9e5123.png)

So I manually removed the image from S3 storage and once again uploaded the new renamed image. This time the same thing happened again, but this time the S3 link to that particular image is access denied. Also, the new image is not visible in S3 this time.

 ![s3](https://global.discourse-cdn.com/meta/original/3X/7/5/7549327bc6e60461c31f97159590c16c80251283.png)

Any guess guys ??

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [September 29, 2018, 4:01am UTC](https://meta.discourse.org/t/access-denied-for-aws-s3-image/98218/2 "2018-09-29T04:01:03Z")

</div>

> [@Pravi](#):
>
> Surprisingly, the newly uploaded image picked up the name of the previously uploaded image. Is that a bug ??

It’s not a bug. We index uploads based on their content. Same content == same upload.

> [@Pravi](#):
>
> So I manually removed the image from S3 storage

Well, yeah, because you didn’t remove the upload record in the database.

In order to fix it, you’ll have to find the record and destroy it using the rails console.

---

<div class="post-metadata">

### Author: ![Pravi](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@Pravi](https://meta.discourse.org/u/Pravi)
#### Post date: [September 29, 2018, 4:35pm UTC](https://meta.discourse.org/t/access-denied-for-aws-s3-image/98218/3 "2018-09-29T16:35:26Z")

</div>

> [@zogstrip](#):
>
> Well, yeah, because you didn’t remove the upload record in the database.

Agreed. But I upload the same image again via the customise theme section, but this time the image hasn’t reached the S3. I am not sure, what I am saying is correct or not, since my background is different. But, once you removed an image from S3 manually, then uploaded the same image via discourse, then the image won’t reach S3.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [September 29, 2018, 4:36pm UTC](https://meta.discourse.org/t/access-denied-for-aws-s3-image/98218/4 "2018-09-29T16:36:53Z")

</div>

That’s because you didn’t remove the record in the database. Since your file has the same SHA, we don’t upload it to S3 since we already have a record in the database.

---

<div class="post-metadata">

### Author: ![Pravi](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@Pravi](https://meta.discourse.org/u/Pravi)
#### Post date: [September 29, 2018, 4:44pm UTC](https://meta.discourse.org/t/access-denied-for-aws-s3-image/98218/5 "2018-09-29T16:44:54Z")

</div>

Is it okay, if I not remove the records from the database ?? Out of curiosity, do discourse have any mechanism to remove broken records periodically?

---

<div class="post-metadata">

### Author: ![dexster234](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@dexster234](https://meta.discourse.org/u/dexster234)
#### Post date: [September 29, 2018, 8:21pm UTC](https://meta.discourse.org/t/access-denied-for-aws-s3-image/98218/6 "2018-09-29T20:21:27Z")

</div>

I came across a similar thread with a problem related to yours, you can check to see if it has just what you are looking for to work out the issue [After setting up S3 - Access denied](https://meta.discourse.org/t/after-setting-up-s3-access-denied/90730)  
or the instruction contained here [How to Setup Amazon S3 Correct Way for Your Discourse Forum – Setup Auto Image and Backup Upload Both to AWS S3](https://crunchify.com/how-to-setup-amazon-s3-correct-way-for-your-discourse-forum-setup-image-upload-and-backup-both-to-aws-s3/)
