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* -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/m24VGM8Ll5AJ. For more options, visit https://groups.google.com/groups/opt_out.
Using Paperclip, you should be able to configure to store your pdfs onto amazon s3. https://github.com/thoughtbot/paperclip Cheers, GT -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Prrc-anHCUYJ. For more options, visit https://groups.google.com/groups/opt_out.
I dont think it will helpful, below is my code, // in my model content = File.read "#{Rails.root}/app/to/mytemplate.html.erb" template = ERB.new(content) html_content = template.result(binding) pdf= WickedPdf.new.pdf_from_string(html_content) save_path = "#{Rails.root}/public/test_pdf.pdf" File.open(save_path, ''wb'') do |file| file << pdf end @photo = Photo.new @photo.avatar = File.open("#{Rails.root}/public/message#{@message.id }.pdf") @photo.save 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? Saravanan.P On Sat, Jan 26, 2013 at 1:22 PM, GT <withhawaii-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Using Paperclip, you should be able to configure to store your pdfs onto > amazon s3. > > https://github.com/thoughtbot/paperclip > > Cheers, > GT > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/Prrc-anHCUYJ. > > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Regards by Saravanan.P -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Sat, Jan 26, 2013 at 9:01 PM, Saravanan P <saravanan.p-tks5Z7IV8F8RmelmmXo44Q@public.gmane.org> wrote:> I dont think it will helpful, below is my code, > > // in my model > > content = File.read "#{Rails.root}/app/to/mytemplate.html.erb" > template = ERB.new(content) > html_content = template.result(binding) > pdf= WickedPdf.new.pdf_from_string(html_content) > save_path = "#{Rails.root}/public/test_pdf.pdf" > File.open(save_path, ''wb'') do |file| > file << pdf > end > @photo = Photo.new > @photo.avatar > File.open("#{Rails.root}/public/message#{@message.id}.pdf") > @photo.save > > 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 (http://fog.io) -- 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: file.public_url Saving a new version of the S3 item: file = bucket.files.get(''test_pdf.pdf'') file.body = newpdf file.save -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
ok Tamouse Thank You. let me try this. :) On Sun, Jan 27, 2013 at 2:28 PM, tamouse mailing lists < tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sat, Jan 26, 2013 at 9:01 PM, Saravanan P <saravanan.p-tks5Z7IV8F8RmelmmXo44Q@public.gmane.org> > wrote: > > I dont think it will helpful, below is my code, > > > > // in my model > > > > content = File.read "#{Rails.root}/app/to/mytemplate.html.erb" > > template = ERB.new(content) > > html_content = template.result(binding) > > pdf= WickedPdf.new.pdf_from_string(html_content) > > save_path = "#{Rails.root}/public/test_pdf.pdf" > > File.open(save_path, ''wb'') do |file| > > file << pdf > > end > > @photo = Photo.new > > @photo.avatar > > File.open("#{Rails.root}/public/message#{@message.id}.pdf") > > @photo.save > > > > 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 (http://fog.io) -- 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: > > file.public_url > > Saving a new version of the S3 item: > > file = bucket.files.get(''test_pdf.pdf'') > file.body = newpdf > file.save > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Regards by Saravanan.P -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.