Upload files on multiple server (S3, Dropbox, ...) - ruby-on-rails

I'm designing a little application using Rails and I need to upload files. I searched and I found paperclip + Carrierwave to do that. I've also seen that it's possible for that gems to specify where to store the uploaded file in the model.
My question is : Using Paperclip, is it possible to know at runtime where the user wants to upload the file and of course is it possible to catch and save the file to the corresponding host ?
Regards

Related

Upload file in Rails 3.2 app - develop engine or use gem?

We are looking to add a simple file uploader to our rails 3.2 app which is a business application (with Rails engines). Here are what we are looking for with the file uploader:
Allow access control to who can do what. For example, sales can upload a contract and acct can view the uploaded contract.
No change to current model. The file uploader acts on its own about file uploading, checking, storing and removing. We are thinking to have a file uploader engine and attach the engine to the Rails app.
File uploaded belongs to a model. For example, uploaded contract copy belongs to a project.
May need to upload file to a remote server.
We are evaluating options of developing our own uploader engine or find a upload gem such as carrierwave or paperclip. Can someone shed a light on rails file uploading and its related issue?
Using a combination of cancan and paperclip is a good option.

How can I upload a GarageBand (.band) file into my rails app?

I am creating a Rails app which should allow users to upload any type of audio file format. I am currently using Carrierwave gem to accomplish this, however CarrierWave will not allow uploads of certain file formats such as .band (GarageBand default format).
Is there a way to accomplish this?
Well, .band is actually a folder containing multiple files. So, yes, carrierwave does not allow uploads of folders. The folder must be converted into a .zip file.

temporary file access using carrierwave rails?

Hi I am a ROR developer and developing an ROR application where user can upload file and share the URL to download.
I am using carrierwave for file upload and storing the file in my application (not in AWS).
I want to give permission for the user to access the upload file only for a certain period of time (for ex:1 hour).
please help me to achieve this without creating any cron jobs or before_filter method?
I found AWS has default feature for this but I am not storing the file in AWS S3. I am storing it in my local application folder, so please guide me how I can achieve this.

how do I add files already stored on s3 to carrierwave backed by same datastore?

I already have files in my s3, which were uploaded via FTP, and I'd just like to attach them to my models, which allow upload via CarrierWave, if I'm using the same bucket to store the files I upload via CarrierWave and the ones I upload via FTP, is there a way to just assign the s3 key for the file to the (new) associated record (via a model) where the file itself is handled via CarrierWave's attachment strategy?
Assuming you have the thumbnails already created, and can store the files in the correct directory on S3, you could simply:
#user.update_column(:image, "your-image-name.png")
This will not execute any callbacks, and carrierwave will assume all processing has already been completed.
That's a lot of assumptions though, so this would likely not work for you in reality.

How should I parse a file in Ruby on Rails to store in a database?

I want to create a simple form for users to upload a file, which will be stored in a database. I also want to display all the submitted files in the database with their name and a link to download the file. Schematically, what's the best way to do this in Rails/how should I store the file in table (which fields should my table have? etc). Thanks!
i would use paperclip gem with the upload to s3 instead of file system
https://github.com/thoughtbot/paperclip
checkout the README, most of the examples are for an image, but works with non-image files as well
use paperclip to upload file, you can store images/file in your database as well as in s3 (AWS)
See below link how to use paperclip in rails with example
Here is the steps how to upload file using paperclip in rails
http://patshaughnessy.net/2009/4/30/paperclip-sample-app
for github
https://github.com/thoughtbot/paperclip
https://github.com/websymphony/Rails3-Paperclip-Uploadify

Resources