fringd / zipline

A gem that lets you stream a zip file from rails
MIT License
289 stars 68 forks source link

404 Not Found when using open-uri for files on AWS S3 #39

Closed rkorzeniec closed 5 years ago

rkorzeniec commented 6 years ago

It seems that either there is a bug, or I have implemented it wrongly, perhaps I can get some input/advise on it.

Issue Unexpected error while processing request: 404 Not Found error received then trying to lazy retrieve the files stored on AWS S3 with open-uri, as in the readme guide

The error is returned when processed, however while debugging with i.e. pry and calling open(invoice.url) it seems that the call is successful as the instance of File is returned and read can be called on it, with what seems like the right file contents.

Code sample

invoices.lazy.map do |invoice| 
  [open(invoice.url), 'invoice_1.pdf']
end

Error snippet

Unexpected error while processing request: 404 Not Found
/Users/.rbenv/versions/2.2.2/lib/ruby/2.2.0/open-uri.rb:358:in `open_http'
/Users/.rbenv/versions/2.2.2/lib/ruby/2.2.0/open-uri.rb:736:in `buffer_open'
/Users/.rbenv/versions/2.2.2/lib/ruby/2.2.0/open-uri.rb:211:in `block in open_loop'
/Users/.rbenv/versions/2.2.2/lib/ruby/2.2.0/open-uri.rb:209:in `catch'
/Users/.rbenv/versions/2.2.2/lib/ruby/2.2.0/open-uri.rb:209:in `open_loop'
/Users/.rbenv/versions/2.2.2/lib/ruby/2.2.0/open-uri.rb:150:in `open_uri'
/Users/.rbenv/versions/2.2.2/lib/ruby/2.2.0/open-uri.rb:716:in `open'
/Users/.rbenv/versions/2.2.2/lib/ruby/2.2.0/open-uri.rb:34:in `open'
fringd commented 6 years ago

The url must be wrong is all that I can think? Can you look at invoice.url in the debugger and verify that it's a working URL?

fringd commented 6 years ago

Some objects have a signed_url or other method that is the one you want instead