Reputation: 5953
I'm trying to save a pdf to S3 by using a tempfile. I'm sure the pdf is being created correctly because I use the same code to email pdfs.
A file is being saved to S3, but it's empty.
pdf is created by CombinePDF.new - so, pdf contains the pdf data.
This is my code:
@file = Tempfile.new('costprojectspdf')
@file.write(pdf)
@obj = @bucket.objects.create("costprojects.pdf", @file.read)
Is @file.read correct? Do I need to @file.close?
Thanks for your help!
Upvotes: 0
Views: 1952
Reputation: 2731
If pdf
is the raw data then this should be fine:
@obj = @bucket.objects.create("costprojects.pdf", pdf.to_pdf)
Upvotes: 1