从 tmp 文件夹 Heroku 打开文件
我有以下哈希参数数组
{
"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/RackMultipart20110818-1-18qnwtj>>,
"method"=>"post",
"access_token"=>"my_access_token",
"format"=>"json"
}
如何使用 File.open()
打开文件。我应该指定哪个路径?
谢谢
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/RackMultipart20110818-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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只想读取文件的内容吗?
如果是这样,请使用
ActionDispatch::Http::UploadedFile
为您提供:
无需使用
File.open
重新打开它。Do you just want to read the contents of the file?
If so, use the interface that
ActionDispatch::Http::UploadedFile
gives you:No need to reopen it with
File.open
.