How to get a real file with S3 using CarrierWave

I have an application that reads the contents of a file and indexes it. I kept them on disk, but now I use Amazon S3, so the following method no longer works.

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.filereturns FileUploaderand doc.file.filereturns the class CarrierWave::Storage::Fog::File.

How can I get a real file?

+5
source share
1 answer

The call @document.file.readwill provide you the contents of the file from S3 to Carrierwave.

+9
source

All Articles