[英]Rails - IMGkit - Errno::EACCES Permission denied error
I am using IMGkit gem in my rails project. 我在Rails项目中使用IMGkit gem。 I also installed wkhtmltoimage-binary
which is necessary for IMGkit to work. 我还安装了wkhtmltoimage-binary
,这对于IMGkit起作用是必需的。 Both IMGkit and wkhtmltoimage-binary are installed via gemfile. IMGkit和wkhtmltoimage-binary都通过gemfile安装。 Under config/initializers/imgkit.rb
i have 在config/initializers/imgkit.rb
我有
IMGKit.configure do |config|
config.wkhtmltoimage = '/Users/Praveen/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/wkhtmltoimage-binary-0.12.2'
config.default_format = :png
end
In apps_controller.rb
在apps_controller.rb
def index
kit = IMGKit.new(html, :quality => 50)
# Get the image BLOB
img = kit.to_img
# Save to a file
file = kit.to_file('/path/to/save/file2.jpg')
# send to browser (Rails - use with #caches_page)
send_data(kit.to_img, :type => "image/jpeg", :disposition => 'inline')
end 结束
When running this i got the following error 运行此时,出现以下错误
Though the folder permission is 777. Any help on this to proceed. 尽管文件夹许可为777。有关此的任何帮助都可以继续。 Thanks in advance. 提前致谢。
I figured it out myself. 我自己弄清楚了。
No need to give the following in imgkit.rb
if you install wkhtmltoimage-binary
via gemfile. 如果通过gemfile安装wkhtmltoimage-binary
,则无需在imgkit.rb
提供以下内容。
config.wkhtmltoimage = '/Users/Praveen/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/wkhtmltoimage-binary-0.12.2'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.