Reading pdfs with RMagick from https gives a unable to open file error

最后都变了- 提交于 2019-12-08 01:01:05

问题


I am trying to read a pdf and save the first page as an image. This method works for http, but it doesn't work for https. I recently posted another related question here:

Reading pdfs with RMagick from https gives a not authorized error

I removed the https line from policy.xml, which got me past the not authorized error. However, a new error happens specific to https:

require 'RMagick'

url = "http://www.ke.tu-darmstadt.de/publications/reports/tud-ke-2008-07.pdf"
image = Magick::Image.read(url + "[0]")
=> [http://www.ke.tu-darmstadt.de/publications/reports/tud-ke-2008-07.pdf[0]=>tud-ke-2008-07.pdf PDF 595x842 595x842+0+0 DirectClass 16-bit 27kb]

url = "https://www.cs.purdue.edu/homes/dgleich/publications/Gleich%202003%20-%20Machine%20Learning%20in%20Computer%20Chess.pdf"
image = Magick::Image.read(url + "[0]")
Magick::ImageMagickError: unable to open file `/tmp/magick-MtiGRdUJ': No such file or directory @ error/constitute.c/ReadImage/583

It seems like it is looking for a file in the /tmp folder that doesn't exist or no longer exists. There is no file with that name anywhere on the server. The http url does create a file in the /tmp folder, so it seems like it might be a bug.

来源:https://stackoverflow.com/questions/37951979/reading-pdfs-with-rmagick-from-https-gives-a-unable-to-open-file-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!