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!
如果pdf
是原始数据,则可以:
@obj = @bucket.objects.create("costprojects.pdf", pdf.to_pdf)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.