Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prawn image on amazon image not found

I am using Prawn 0.12.0 in a Rails 3.2.12 app.

If I have an image on my local server it can show in a standard rails view, and I can also have it shown in a Prawn PDF using the following code

@logo = company.logo_url(:large).to_s    
image @logo, :fit => [83.mm, 26.mm]

So far, so good. If I change the location of the image to be on Amazon S3 I get the following

I am able to show in a standard Rails view no problem If I try to display the image in a Prawn pdf I get the following error

Argument error (https://mydomain.s3.amazonaws.com/uploads/company/logo/20/large_2275_logo.png not found):

And if I then copy and paste that url into a browser, the image shows fine.

So to recap...

  1. I am able to use the Prawn image command for a local image, indicating I am using the Prawn syntax correctly
  2. I can access an image on Amazon S3 using a direct browser and a Rails view, indicating that the URL is correct
  3. BUT, I can not access the image on Amazon S3 from Prawn

Has anyone seen anything similar, or have any suggestions?

Michael

like image 983
Michael Moulsdale Avatar asked Sep 05 '13 06:09

Michael Moulsdale


2 Answers

I had the same problem, I've solved with

require 'open-uri'

image open("hxxp://www.thesite.com/theimage.png")

like image 63
elvi3nto Avatar answered Sep 28 '22 19:09

elvi3nto


With the recent releases of Prawn, you can achieve loading remote images without requiring open-uri;

image open("http://example.com/remote_image.pdf"), at: [300, 100], width: 100, height: 100
like image 21
zakelfassi Avatar answered Sep 28 '22 19:09

zakelfassi