Reputation: 1
I have a problem, I upload a file in amazon and I can get the url and the amazon key file but when i try to read the file in my model with CSV.read(file_path, headers: true) I get the error No such file or directory @ rb_sysopen, what I can do for read the file?
Upvotes: 0
Views: 1236
Reputation: 18784
CSV.read()
needs the file to be a local on-disk filename, file handle or IO object, but your Amazon key file or URL is not one of those things.
You'll likely need to download the contents to a file (or Tempfile), then read it with something like this:
require 'open-uri' # gives us the `open()` method in this namespace
open(amazon_url) do |file|
CSV.read(file, headers: true) do |csv|
# do something with csv data here
end
end
Upvotes: 1