I have an application that reads the content of a file and indexes it. I was storing them in the disk itself, but now I'm using Amazon S3, so the following method doesn't work anymore.
It was something like this:
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
returns the FileUploader
, and doc.file.file
returns the CarrierWave::Storage::Fog::File
class.
How can I get the real file?
Calling @document.file.read
will get you the contents of the file from S3 in Carrierwave.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With