Created
March 7, 2009 07:29
-
-
Save akia/75261 to your computer and use it in GitHub Desktop.
[ruby] upload file
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 uploaded_file(tmp_filename, content_type, filename) | |
t = Tempfile.new(filename) | |
t.binmode | |
path = RAILS_ROOT + "/test/fixtures/files/" + tmp_filename | |
FileUtils.copy_file(path, t.path) | |
(class << t; self; end).class_eval do | |
alias local_path path | |
define_method(:original_filename) { filename } | |
define_method(:content_type) { content_type } | |
end | |
return t | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment