我有一个应用程序可以读取文件的内容并为其编制索引。我将它们存储在磁盘本身中,但现在我使用的是 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
返回 FileUploader
,doc.file.file
返回 CarrierWave::Storage::Fog::文件
类。
如何获取真实文件?
最佳答案
调用 @document.file.read
将使您从 Carrierwave 中的 S3 获取文件的内容。
关于ruby - 如何使用 CarrierWave 从 S3 获取真实文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11917027/