如何使用CarrierWave从S3获取真实文件

我有一个应用程序,它读取文件的内容并对其进行索引。 我将它们存储在磁盘本身,但现在我正在使用Amazon S3,因此以下方法不再起作用。

它是这样的:

def perform(docId) @document = Document.find(docId) if @document.file? #You should't create a new version @document.versionless do |doc| @document.file_content = Cloudoc::Extractor.new.extract(@document.file.file) @document.save end end end 

@document.file返回FileUploaderdoc.file.file返回CarrierWave::Storage::Fog::File类。

我怎样才能获得真实的文件?

调用@document.file.read将从Carrierwave中获取S3中文件的内容。