Rake任务创建CSV,然后上传到S3。怎么样? [英] Rake task creates CSV and then upload to S3. How?

查看:103
本文介绍了Rake任务创建CSV,然后上传到S3。怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个创建一个CSV文件rake任务。现在我保存这个文件到我的/ tmp目录的文件夹(我用的Heroku)。这个CSV文件不与任何型号有关,它只是一些数据,我从多个API拉,再加上从我的模型的一些数据。

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.

我想下载从Heroku的文件,但这似乎是不可能的。所以,我的问题是:哪个宝石我在试图寻找以上传文件到Amazon S3?我见过像回形针宝石,但是,这似乎是一个模型相关联,而不是我的情况。我只想上传CSV文件,我将在/ tmp目录,进入我的Amazon S3的桶中。

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.

感谢

推荐答案

您可以使用 AWS-S3宝石

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

您应该定义你的tmp文件的确切路径,例如:

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

open("#{Rails.root}/tmp/source_file.tmp")

这篇关于Rake任务创建CSV,然后上传到S3。怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆