Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3 Prawn PDF

upon adding an image to my prawn document and trying to pull that image from Amazon S3 storage I get the following error

ArgumentError (http://s3.amazonaws.com/briefbucket/photos/2/small/259823_1583726693707_1851950185_973122_7126850_n.jpg?1326839482 not found):

however i looked in my storage folder, the jpg is there. I noticed that the ending file name in prawn is "jpg?1326839482"?

any help would be appreciated.

like image 715
FrankHock Avatar asked Nov 28 '25 17:11

FrankHock


1 Answers

Alright, I had the same issue today. Now: I'm using Amazon S3 and loading images uploaded by users. Solution as follows:

if @user.avatar? #in case user didn't upload anything
  image open("#{ @user.avatar(:small).to_s.sub!(/\?.+\Z/, '') }")
end

Following

.to_s.sub!(/\?.+\Z/, '') 

is used the get rid of all stuff after "?"

Before I have moved to amazon i was not using "open" which was causing the issue.

Let me know if this helps.

like image 116
Lukasz Muzyka Avatar answered Dec 02 '25 05:12

Lukasz Muzyka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!