Understanding how uploading images and files work

AI-generated summary

The discussion revolves around how image and file uploads work in Discourse. verilog15 asks about the storage location of uploaded images and whether they are deleted immediately when removed from a topic. Falco explains that images are stored in /var/discourse/shared/standalone/uploads/default/ and are removed only if the clean up uploads feature is enabled, with a delay based on the clean orphan uploads grace period hours. verilog15 raises concerns about potential abuse through rapid uploads and deletions, which Falco addresses by noting restrictions such as one image per topic for new users, a 4MB limit for images, deduplication, and trust-level settings. verilog15 also asks if the 4MB limit applies to PDFs, and Falco clarifies that PDFs are treated as files and follow the max attachment size kb setting instead.

Hello all! :slight_smile:
Due to storage limitations, I was wondering how uploading images/files work. As I understand, everytime, user uploads a new image to the forum, it saves it somewhere. The question is where exactly? Also, what if admin or user removes that image from the topic, will this image be removed from that storage area? (if it is, will it remove the image right away or will it wait for a period of time).
Thank you :stuck_out_tongue:

At /var/discourse/shared/standalone/uploads/default/ on the server.

Yes as long as clean up uploads is enabled.

Upload will be removed after clean orphan uploads grace period hours.

Thanks for explaining :slight_smile:
What if user will try to do some sort of “abuse” like upload bunch of images and remove each one after a few seconds. They all will be saved in the ../default directory and I could ran out of storage?

Discourse new users can only upload one image per topic. Also image max size is just 4MB, so to fill a coupe of gigabytes a user will need a lot of images, and since we deduplicate uploads it will need to be all different. There is also min trust to post images that can be tweaked to TL2 if new accounts cause you problems.

If you can’t afford user uploads just disable them and tell your users to publish those in sites like https://imgur.com/ like Reddit did for years.

The 4MB limitation is also true of documents like PDF?

No, PDF aren’t images. Those are handled as files and follow the max attachment size kb site setting.