2017-07-06 137 views
0

我正在嘗試使用Rmagick將pdf轉換爲jpeg圖像。我遇到了一些麻煩,下面的代碼:當我給它這個pdf_string使用Rmagick將pdf轉換爲jpeg

"https://staging.shurpa.com/deliveries/BtrPsIxl/label.pdf" 
"/var/folders/qm/yk_w5d9545j_6wqk6100dhjm0000gq/T/order20170706-43294- 
15myct1.png" 

Magick::ImageMagickError: unable to open file `/var/folders/qm/yk_w5d9545j_6wqk6100dhjm0000gq/T/magick-43294MCNyzIu4Oenn': No such file or directory @ error/constitute.c/ReadImage/544from/Users/timnaughton/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0/lib/rmagick_internal.rb:1616:in `read' 

然而代碼工作完全正常:

"https://shippo-delivery-east.s3.amazonaws.com/b2a3e1cd070748cd80b492aa421832a3.pdf?Signature=nf6woycGiOydPI8eSnLcq3r0tEc%3D&Expires=1530816480&AWSAccessKeyId=AKIAJGLCC5MYLLWIG42A" 

回答

0

pdf_link = "https://staging.shurpa.com/deliveries/BtrPsIxl/label.pdf" 

file = Tempfile.new(['order', '.jpeg']) 
    p pdf_link 
    p file.path 
    im = ImageList.new(pdf_link) 
    puts "SUPP" 
    im.write(file.path.to_s) 

我收到此錯誤這個服務向我提供pdf似乎存在問題。 pdf最近更改爲安全狀態,我需要使用訪問密鑰。這導致rmagick無法訪問映像文件並返回錯誤。