On 19 Aug 2009, at 07:43, Charanya Nagarajan wrote:
> I wish to upload a file not from the view but from the controller
> itself.
> I have the file''s path and mimetype and size.
> I would like to know How it can be done directly from the controller
I always prefer to actually generate an uploader object just as it  
would come from the view itself.
# Mock method to simulate an actual uploaded file
def mock_uploader(path, type = ''application/octet-stream'')
   uploader = ActionController::UploadedStringIO.new
   uploader.original_path = path
   uploader.content_type = type
   def uploader.read
     File.read(original_path)
   end
   def uploader.size
     File.stat(original_path).size
   end
   uploader
end
Best regards
Peter De Berdt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---