2011-01-30 7 views
1

사용자에게 pdf를 보내려고하지만 send_file 및 send_data가 작동하는 데 심각한 문제가 있습니다.레일 send_file 및 send_data 0 바이트 파일을 보냅니다.

tmp = Tempfile.new('filled') 
new_tmp_path = PDFPrint.fill_form_using_pdftk(template_path, tmp.path) 
send_file (new_tmp_path, :filename => 'filled.pdf') 

브라우저에서 다운로드하라는 메시지가 표시되지만 다운로드 한 filled.pdf 파일의 크기는 0입니다. 나는 new_tmp_path 내가이 시도

(좋은, 작성 내용) 유효한 PDF를 포함 않음을 확인했습니다 :

File.open(new_tmp_path, 'r') do |f| 
    send_data(f.read, :filename => "filled.pdf") 
end 

그러나이 또한 동안, 나에게 같은 download-> 0 바이트 문제를 제공합니다 서버의 파일 (new_tmp_path)은 완벽한 내용을 가지고 있습니다.

감사합니다,

답변

0

시도가 읽기 this thread

send_file '/path/to.jpeg', :type => 'image/jpeg', :disposition => 'inline' 

를 작동하는지 확인하는 간단한 파일을 전송, 나는 당신이 필요한 모든 것을 갖추고 있습니다 생각합니다.

+0

PDFTK에서 생성 한 파일을 보내기 전에 "플러시 (flush)"해야한다는 것이 밝혀졌습니다. 질문에 대한 자세한 내용을 언급하지 않아서 죄송합니다. – Dominic

관련 문제