我正在尝试允许上传 pdf 文件。pdf 文件上传后,aPaperclip::Processor
会在其 make 实例方法中将其转换为文本文件。然后,我想解析文本文件以填充ActiveRecord
类。如何访问处理器在其 make 实例方法中返回的已处理文件?
代码骨架在这里:
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
欣赏你的想法。