qpixel icon indicating copy to clipboard operation
qpixel copied to clipboard

Error when files are not stored on Amazon S3

Open Taeir opened this issue 3 years ago • 1 comments

Describe the bug Whenever the storage is set to be anything but S3, (e.g. stored locally), the application will not be able to find the files again (it does store them correctly, but it does not serve them correctly).

This is an issue in development (where files are probably served locally), but also for us in production. We are bound by strict regulations which mean we cannot easily use external services like Amazon to store our bulk data. Instead, we have our own data center and we store bulk data on NFS volumes which are replicated across multiple locations (from the perspective of the application, that is "local" on disk).

Reason:

  • ApplicationController#upload is called for fetching a file (the name of that method is rather confusing)
  • It redirects to UploadsHelper#upload_remote_url
  • This method attempts to retrieve the bucket in which the file is stored.

Since the system was not using S3, fetching the bucket name fails.

To Reproduce Steps to reproduce the behavior:

  1. Start the development environment with default settings (or at least storage local and no S3 configured)
  2. Log in
  3. Upload a file, e.g. an avatar
  4. Save
  5. Observe that the avatar is not displayed, and is served with error 500.

Expected behavior The system serves the file from the location wherever it is stored.

Additional context To solve this while maintaining the special caching behavior in upload_remote_url, a check needs to be made to see which type of service is currently active. Unfortunately, using is_a?(S3Service) gives an error because the class S3Service is not loaded in the case no S3Service is defined. We can work around this by checking the class name, though this is a bit less clean.

Taeir avatar Aug 13 '22 18:08 Taeir

Oops! That's certainly not intended behavior. We use S3 for our instance but we didn't intend to require any particular shared storage. Thanks for the report.

cellio avatar Aug 14 '22 02:08 cellio