Created
April 27, 2012 22:38
-
-
Save notch8-old/2513998 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
def create_upload_file(options = {}) | |
if options[:file] | |
options = { | |
"content_type" => "tmp", | |
"size" => File.size?(options[:file].path), | |
"tempfile" => options[:file], | |
"original_filename" => options[:file].path.split(File::SEPARATOR).last | |
}.merge(options) | |
elsif options[:data] && options[:file_name] | |
options = { | |
"content_type" => "tmp", | |
"size" => options[:data].size, | |
"tempfile" => StringIO.new(options[:data]), | |
"original_filename" => options[:original_filename] | |
}.merge(options) | |
else | |
raise "You need to specify either :file or both :data and :original_filename for this method" | |
end | |
Hashie::Mash.new(options) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment