Ruby on Rails Thursday, February 12, 2015

I just wanted to add to this... I know I am 5 years too late, but I
didn't want anyone else to be led astray.

You should be able to pull anything you can download in your browser
into your app using tempfile. I had to play with it for a while, but
something like this worked:

require "open-uri"
url = "whatev.com/file_id"
file_name = "local_filename.pdf"

Tempfile.new(file_name).tap do |file|
file.binmode
file.write(open(url).read)
file.close
end

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f883dc2e159eb7c592b922dc6fb06f68%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment