开发者

Open file from tmp folder Heroku

I have the following hash params array

{
  "message"=>"My message", 
  "image"=>#<ActionDispatch::Http::UploadedFile:0x00000004242490 
           @original_filename="neEZYMAnBI.jpg", 
           @content_type="application/octet-stream", 
           @headers="Content-Disposition: form-data; name=\"image\"; filename=\"/home/user/public/direct/fb_images/neEZYMAnBI.jpg\"\r\nContent-Type: application/octet-stream\r\n", 
           @tempfile=#<File:/app/tmp/RackMult开发者_运维技巧ipart20110818-1-18qnwtj>>, 
   "method"=>"post", 
   "access_token"=>"my_access_token", 
   "format"=>"json"
}

How can I open the file using File.open(). Which path should I specify?

Thanks


Do you just want to read the contents of the file?

If so, use the interface that ActionDispatch::Http::UploadedFile gives you:

params[:image].read

No need to reopen it with File.open.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜