Load Image Attachments Directly from S3

Akesson

Member
I would like to propose an improvement in how public image attachments are handled in public forums by fetching them directly from the S3 source, similar to how videos and thumbnails are handled today. This could offer several benefits, including:
  • Faster response times: By loading images directly from S3 without burdening the web server, we can reduce loading times and enhance the user experience.
  • Reduced load on the web server
This could be a setting at the forum level, allowing private attachments to be retained for private forums.
 
Last edited:
Upvote 1
This can effectively be done with the exception of permissions for private attachments. it's kinda of an all or nothing bypass using an add on and cloudflare rules


 
Thank you! Changing the header seems to solve the issue for those who want to use a CDN.

It was probably unnecessary for me to mention CDN, as I don’t plan on using one myself. Instead, I would prefer the attachments to be linked directly from object storage, without being streamed through the web server as an extra step.

So, I would like the image links to change from: attachments/my_file-jpg.1/
to: https://my-s3.com/my_file.jpg

Like videos, avatar and thumbnails.
 
You will lose functionality if you do that - such as tracking hits/views of the file and anything else that gets logged in xf for proxy settings/etc.

I don't know of a way to do that with turning knobs, but it certainly could be done with an addon.
 
Attachment thumbnails are already loaded directly since they exist in the data abstracted filesystem (meant for direct public access). Loading the attachments themselves from the internal_data filesystem would be a bad idea because you are exposing your internal data to be accessible public.

That being said, you could use S3 presigned URLs to do it (where your server generates a presigned URL for the user that expires shortly to give them a brief window of access). It's something I did with my Cloudflare addon (when you use R2 for storing things). So I know it can be done, but not sure anyone is really maintaining a feature-rich S3 addon these days.

1729705971162.webp
 
Back
Top Bottom