All threads / Download large files from an external server with permissions

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Download large files from an external server with permissions

Jon Williams asked in Rails

I have a rails application that requires file downloading. To download the files, permission is required - in this case only a logged in user can download the files. Currently, this is working as the files are on within the applications public folder. The problem is that some files are massive, and when being downloaded in turn kill the application until the download is complete.

It would be nice to separate the file from the application to prevent this (even better to host the files on a different server) but keeping the required permissions/authentication.

Is this possible? has anyone experienced this and have some adice?

Thanks!!!

Hi Jon, I'd try using an s3 bucket on AWS with either the carrierwave gem or paperclip gem and then secure the s3 bucket to only allow authenticated users to access it. Here are a couple of links that might help:

If the file download speed is going to hurt your app, perhaps moving it off into a background job with something like Sidekiq would be the answer. I've never used Sidkiq for this but I'd imagine its possible.

Lastly, why are the files so large to begin with? Do they have to be? If not, then perhaps upon ingestion of the files you resize them to something a little more "web friendly" to speed up download times in the future.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 34,885+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.