Created
July 22, 2008 15:43
-
-
Save arikan/1094 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Upload a file from a remote URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_remote_file(uri) | |
require 'open-uri' | |
begin | |
uploadedfile = nil | |
open(uri) do |remote| | |
uploadedfile = StringIO.new(remote.read) | |
filename = File.basename(uri) | |
(class << uploadedfile; self; end).class_eval do | |
define_method(:local_path) { "" } | |
define_method(:original_filename) { filename } | |
define_method(:content_type) { "application/octet-stream" } | |
end | |
end | |
return uploadedfile | |
rescue | |
return "" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment