0

I have a rake task that creates a CSV file. Right now I am storing this file into my /tmp folder (I am using Heroku). This CSV file is not associated with any model, it's just some data I pull from several APIs, combined with some data from my models.

I would like to download this file from Heroku, but this seems not possible. So, my question is: Which gem am I trying to look for in order to upload that file to Amazon S3? I have seen gems like Paperclip, but that seems to be associated with a model, and that is not my case. I just want to upload that CSV file that I will have in /tmp, into my Amazon S3 bucket.

Thanks

4

2 回答 2

2

You can use aws-s3 gem

S3Object.store('filename_in_s3.txt', open("source_file.tmp"), 'bucket_name')

You should define the exact path of your tmp file, for example:

open("#{Rails.root}/tmp/source_file.tmp")
于 2013-07-08T12:35:15.670 回答
0

CarrierWave can directly interface your Ruby application with S3 directly via the Fog library. Rather than operating on the model level, CarrierWave utilizes a Uploader class where you can cull from across your APIs and datasources, which is precisely what you're trying to accomplish.

于 2013-07-08T12:27:38.103 回答