store pdf directly to amazon

Hello Everyone,

I am using wicked pdf and rails 3.2.8.

I can generate pdf (html to pdf).

How can i store my pdf file into amazon s3 without storing in Local.

Please help

Using Paperclip, you should be able to configure to store your pdfs onto amazon s3.



I dont think it will helpful, below is my code,

// in my model

content = “#{Rails.root}/app/to/mytemplate.html.erb”
template =

  html_content = template.result(binding)
  save_path = "#{Rails.root}/public/test_pdf.pdf", 'wb') do |file|

   file << pdf
  @photo =
  @photo.avatar ="#{Rails.root}/public/message#{@[](}.pdf")

The above code will generate pdf and store file locally then only i am uploading into s3 server.

But i need to store s3 without store into local. Is that possible?


Try Fog ( -- you can open up a storage connection and
write directly to S3:

Creating the S3 item (new) after making connection and bucket:

file = bucket.files.create(
  :key => 'test_pdf.pdf',
  :body => pdf,
  :public => true

and the public URL is at:


Saving a new version of the S3 item:

file = bucket.files.get('test_pdf.pdf')
file.body = newpdf

ok Tamouse Thank You. let me try this. :slight_smile: