简体   繁体   English

使用ruby on rails将映像存储在内存或浏览器缓存中

[英]Store an image in memory or in a browser cache with ruby on rails

Now in my rails app i have stored one image from url,that stored in my system tmp folder. 现在在我的rails应用程序中,我已经存储了一个存储在我的系统tmp文件夹中的url图像。 But the problem is i am using heroku to running this rails app, so how will be the storing process when running with heroku? 但问题是我使用heroku来运行这个rails应用程序,那么在运行heroku时如何存储过程呢?

def mail
@image = https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=5&choe=UTF-8
path_image = "/tmp/img.png"
open(@image) do |chart|
 File.open(path_image, 'wb') {|f| f.write chart.read }
end
welcome(path_image)
end

Thanks 谢谢

Heroku的开发中心所述 ,您可以将临时文件存储在#{RAILS_ROOT}/tmp/ (Rails 2)或Rails.root.join('tmp') (Rails 3)目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM