【发布时间】:2016-01-13 19:15:01
【问题描述】:
我有部署到 Heroku 的应用程序。我添加了通过 CSV 上传用户的功能。为此,我提供了 CSV 上传功能(使用回形针 gem)。
这是我读取文件和创建新用户的代码
def import(file)
CSV.foreach(file.path, headers: true) do |row|
row_hash = row.to_hash.values
data = row_hash[0].split("\t")
.
.
.
end
在本地它工作正常。但是在heroku上它给了我以下错误
Errno::ENOENT: No such file or directory @ rb_sysopen - https://s3.amazonaws.com/..../..../sample_csv(2).csv
我参考了以下链接 Errno::ENOENT (No such file or directory) in amazon-s3
File reading from Amazon server, ruby on rails, no match route
但没有任何成功。为了进行更多调试,我从本地 rails 控制台尝试了相同的 url,它给了我同样的错误。
2.2.2 :008 > cp = "https://s3.amazonaws.com/..../..../sample_csv(2).csv"
2.2.2 :008 > f = File.open(cp, "r")
Errno::ENOENT: No such file or directory @ rb_sysopen - https://s3.amazonaws.com
还尝试打开 uri http://ruby-doc.org/stdlib-2.1.0/libdoc/open-uri/rdoc/OpenURI.html。
我可以从浏览器下载相同的文件。
谁能告诉我如何解决这个错误。是否有任何存储桶权限问题(我已经为存储桶提供了开放访问权限)。
【问题讨论】:
标签: ruby-on-rails ruby amazon-web-services heroku amazon-s3