[英]Rails 5 - download a paperclip attachment
在我要學習RoR的應用程序中,我想自動下載附件的pdf。 附回形針。 然后使用pdfinfo獲取pdf屬性。
在我的annotation.rb
模型中,我使用
has_attached_file :file,
styles: { large: "600x600>", medium: "500x500>", thumb: "150x150#" },
default_url: "/images/:style/missing.png"
在我的AnnotationsController中
require 'pdfinfo'
pdfinfo = Pdfinfo.new('@annotation.file.path')
page_count = pdfinfo.page_count
這引發一個錯誤
注釋中的Pdfinfo :: CommandFailedController#pdf pdfinfo -f 0 -l -1 -enc UTF-8 @ annotation.file.path
此錯誤是什么意思,我該如何讀取文件? 我了解了有關使用send_file下載的信息,但沒有成功。
您正在將文字字符串傳遞給新方法。 您需要刪除引號。
require 'pdfinfo'
pdfinfo = Pdfinfo.new(@annotation.file.path)
page_count = pdfinfo.page_count
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.