Uploads to external storage

Hi all,

I’m trying to change the Discourse uploads location to an external storage location on my self-hosted instance due to space constraints. I have a CIFS share mounted and already copied all existing uploads with the same directory structure to the mounted location.

Then, I added the following lines to the app.yml:

- volumes:
  - volume:
      host: /<storage-location>/uploads
      guest: /shared/uploads

After rebuilding the container with ./launcher rebuild app (I’m the root user), the images are not visible anymore on the website. I appears that they all return a code 404.

I tried mounting the CIFS share as root:root and _default_hostname:www-data, but every time, images don’t show up.

What is the best (or correct) way to perform this change of locations for uploads?

Thanks in advance guys!

Here is what is the default:

volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared

You probably want something like this:

volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /your/cifs/share/discourse-uploads
      guest: /shared/uploads
1 Like

True! I tried it that way, and it worked, just keeping in mind that the mounted storage location must have the right permissions. root:root doesn’t work, but _default_hostname:www-data seems to work.

Another thing I noticed: uploads in topics, even with moving them to the new storage location, don’t work anymore and have to be re-uploaded. Other images/uploads (logos, headers etc) work fine.

Thanks!

That shouldn’t be. Maybe you copied the files to the wrong place.

I was thinking that too, but I double checked that I copied the whole uploads folder from shared/standalone/ to my external storage location, including the default and other sub folders.

It’s important to mention that I tried a few times to change the uploads location with different configurations for the external storage (mostly different file and folder permissions) and in between executed a rake posts:rebake in an attempt to let the attachments work again, and maybe somewhere in between the problem occurred…

It’s strange that uploading it again fixes it.

You can look at Uploads.pluck(:url) in rails and see if there’s something strange there.