Çözüldü, bkz. Alttaki düzenleme. Benim 3.1 raylar iseSistem tarafından oluşturulan PDF'yi S3 üzerinde depolayın.
Böyle bir pdf oluşturma ediyorum app:
Sonradef show
@contributor = Contributor.find(params[:id])
respond_to do |format|
format.pdf {
html = render_to_string(:action => "show.html.erb")
kit = PDFKit.new(html)
kit.stylesheets << "#{Rails.root}/app/assets/stylesheets/unique/print.css"
thepdf = send_data kit.to_pdf, :filename => "blah.pdf", :type => 'application/pdf'
redirect_to :action => save_to_s3
}
end
Ben Paperclip ile yükleyerek S3 PDF oluşturulan mağazaya çalışıyorum:
def save_to_s3
html = render_to_string(:action => "show.html.erb")
kit = PDFKit.new(html)
kit.stylesheets << "#{Rails.root}/app/assets/stylesheets/unique/print.css"
roy = Royarchive.new(:client_id => @contributor.client_id)
f = File.open("blah.pdf", 'w+')
f.write kit.to_pdf
roy.pdf = f
roy.save!
end
Ama bana bu bana "\x9C" from ASCII-8BIT to UTF-8
Bunu oluşturmak için Paperclip'i nasıl kullanabilirim S3 için pdf? Heroku kullanıyorum, böylece sunucuda geçici bir dosya kaydedemiyorum ve yükleyemiyorum. benim kötü
Ah
çözüldü //// , sen can store files for the duration of the session at root.Yani bu çalışır:
def show
@contributors = Contributor.where(:client_id => current_user.client_id).paginate(:page => params[:page])
@contributor = Contributor.where(:client_id => current_user.client_id).find(params[:id])
respond_to do |format|
format.html
format.pdf {
html = render_to_string(:action => "show.html.erb")
kit = PDFKit.new(html)
kit.stylesheets << "#{Rails.root}/app/assets/stylesheets/unique/print.css"
send_data kit.to_pdf, :filename => "name.pdf", :type => 'application/pdf'
@thepdf = kit.to_file("#{Rails.root}/tmp/name.pdf")
roy = Royarchive.new(:client_id => @contributor.client_id)
roy.pdf = @thepdf
roy.save!
}
end
end
I will - sen ben bile yazma 8 saat içinde, kendi Q cevap şöyle dursun, kabul etmek zorunda daha fazla temsilcisi gerekir. – snowangel