# File Reference and Deletion, will it really be deleted?

**URL:** https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527
**Category:** Feature
**Created:** [May 11, 2017, 4:28pm UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527 "2017-05-11T16:28:48Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![xiasummer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xiasummer/32/82790_2.png) [@xiasummer](https://meta.discourse.org/u/xiasummer)
#### Post date: [May 11, 2017, 4:28pm UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/1 "2017-05-11T16:28:48Z")

</div>

I have a small server with only 20G of storage with my Discourse running on it. So I can’t let people upload too big files——of course if it is very important it should still be uploaded, but if not so important, it should not.

So I set the biggest upload file size 100M.

But I see many not so important files uploaded and the back-up quickly increases.

Here is a really small file I uploaded as an example:

[try file.csv](https://global.discourse-cdn.com/meta/original/3X/f/8/f8c1d87006fbf7e5cc4b026c3138bc046883dc71.csv) (6 字节)

with codes to be

```plaintext
<a class="attachment" href="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/f/8/f8c1d87006fbf7e5cc4b026c3138bc046883dc71.csv">try file.csv</a> 

```

What if I just delete such codes. Will the file “try file.csv” really be deleted from the server and will not cause any more burden on Discourse Backup File?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [May 11, 2017, 4:34pm UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/2 "2017-05-11T16:34:54Z")

</div>

If `clean up uploads` is enabled, all uploads not referenced in posts will be removed after `clean orphan uploads grace period hours`.

If space is a problem, isn’t 100MB files a little too much? 5 or 10MB is enough most times.

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [May 11, 2017, 4:47pm UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/3 "2017-05-11T16:47:09Z")

</div>

> [@xiasummer](#):
>
> I have a small server with only 20G of storage with my Discourse running on it. So I can’t let people upload too big files

Consider setting up:

> [@Set up file and image uploads to S3](https://meta.discourse.org/t/setting-up-file-and-image-uploads-to-s3/7229):
>
> So, you want to use S3 to handle image uploads? Here’s the definitive guide, but also see [Configure an S3 compatible object storage provider for uploads](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916) to see how to configure your app.yml. S3 registration Head over to [https://aws.amazon.com/free/](https://aws.amazon.com/free/) and click on [Create a Free Account] During the create account process, make sure you provide payment information, otherwise you won’t be able to use S3. There’s no registration fee, you will only be charged for [what you use](https://aws.amazon.com/s3/pricing/), if you exceed the [AWS …](https://aws.amazon.com/free/)

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [May 12, 2017, 9:56am UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/4 "2017-05-12T09:56:09Z")

</div>

> [@Falco](#):
>
> If clean up uploads is enabled, all uploads not referenced in posts will be removed after clean orphan uploads grace period hours.

Does this also affect attachments referenced in deleted posts?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [May 12, 2017, 11:47am UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/5 "2017-05-12T11:47:50Z")

</div>

Yes. If a post completely deleted and removed from database and it’s attachments not referenced anywhere else then it will be removed.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [May 12, 2017, 12:05pm UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/6 "2017-05-12T12:05:34Z")

</div>

…so that means that “deletion” in the UI or editing the post so only an old revision contains the link is _not_ enough to get a file removed, right?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [May 12, 2017, 12:20pm UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/7 "2017-05-12T12:20:23Z")

</div>

From my understanding of the current code

If admin can see a post even after deletion (in soft delete or hidden mode) then it means post is not deleted in db. Then it will not removed.

> [@fefrei](#):
>
> editing the post so only an old revision contains the link

In this case the media will be removed.

---

<div class="post-metadata">

### Author: ![trobiyo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/trobiyo/32/311872_2.png) [@trobiyo](https://meta.discourse.org/u/trobiyo)
#### Post date: [July 23, 2018, 6:24pm UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/8 "2018-07-23T18:24:13Z")

</div>

Hi @vinothkannans

Could you please confirm that, in the latest versions (v.2.0.2 and so), when an administrator deletes topics/posts with attachments from UI, either individually or in bulk, those attachments are never removed from the server?

In case they aren’t, what’s the best approach to totally removed from server?

Cheers,  
Ismael

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [July 26, 2018, 11:14am UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/9 "2018-07-26T11:14:18Z")

</div>

> [@Do unlinked files get auto-deleted?](https://meta.discourse.org/t/do-unlinked-files-get-auto-deleted/92215):
>
> Say I drop an image in a post and some time later I decide to remove it by editing the post and erasing the markdown image link. Does the file get deleted from the server after some time? If not, is there any way I can do that manually as a regular user?

Also there are many other related topics.

---

<div class="post-metadata">

### Author: ![trobiyo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/trobiyo/32/311872_2.png) [@trobiyo](https://meta.discourse.org/u/trobiyo)
#### Post date: [July 26, 2018, 12:08pm UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/10 "2018-07-26T12:08:38Z")

</div>

Yes, exactly, that’s what I was looking for 👌

Thank you very much!

---

<div class="post-metadata">

### Author: ![sbernhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sbernhard/32/208186_2.png) [@sbernhard](https://meta.discourse.org/u/sbernhard)
#### Post date: [January 19, 2021, 11:31pm UTC](https://meta.discourse.org/t/file-reference-and-deletion-will-it-really-be-deleted/62527/11 "2021-01-19T23:31:27Z")

</div>

when are uploaded files to private messages are deleted?

Additionally, it would be great to have something like a “self-destroying” private message which will delete the sender and receiver message including the attached files after X hours /days.
