2012-07-06 4 views
1

pdf 파일 업로드를 허용하려고합니다. pdf 파일을 업로드하면 Paperclip::Processor은 make 인스턴스 메소드에서 텍스트 파일로 변환합니다. 그런 다음 텍스트 파일을 구문 분석하여 ActiveRecord 클래스를 채 웁니다. 프로세서가 반환 한 처리 된 파일에 make 인스턴스 메소드로 어떻게 액세스합니까? 프로세서 #에서 반환 한 결과에 액세스하는 방법 paperclip의 after_post_process 콜백?

코드 골격

은 여기에 있습니다 :

module Paperclip 
    class PdfToText < Processor 
    ... 
    def make 
     dst = File.new(..) 
     #do something to dst 
     dst 
    end 
    end 
end 

class Xyz < ActiveRecord::Base 
    has_attached_file :source_file, ..., :processors =>[:pdftotext] 

    after_post_process :do_it 

    def do_it 
    # I would like to access the dst file returned in make of the processor PdfToText 
    end 
end 

이 의견을 주셔서 감사합니다.

답변

1

어떨까요?

source_file.queued_for_write[:original].path 
관련 문제