2016-10-07 4 views
0

RoR을 배우기 위해 구축중인 앱에서 첨부 된 PDF를 자동으로 다운로드하고 싶습니다. 클립으로 붙인다. pdfinfo를 사용하여 pdf 특성을 얻으십시오. 내 annotation.rb 모델에서레일 5 - 클립 첨부 파일을 다운로드

내 AnnotationsController에서

has_attached_file :file, 
    styles: { large: "600x600>", medium: "500x500>", thumb: "150x150#" }, 
    default_url: "/images/:style/missing.png" 

를 사용하여 첨부 할 것은

require 'pdfinfo' 
    pdfinfo = Pdfinfo.new('@annotation.file.path') 
    page_count = pdfinfo.page_count 

이 오류를 발생

Pdfinfo :: -f 0 pdfinfo AnnotationsController 번호를 PDF로 CommandFailed -l -1 -enc UTF-8 @ annotation.file.path

이 오류는 무엇을 의미하며 어떻게 파일을 읽을 수 있습니까? send_file을 사용하여 다운로드하는 방법을 알았지 만 성공하지 못했습니다.

답변

0

리터럴 문자열을 새 메서드에 전달하고 있습니다. 따옴표를 제거해야합니다.

require 'pdfinfo' 
pdfinfo = Pdfinfo.new(@annotation.file.path) 
page_count = pdfinfo.page_count 
관련 문제