inicio mail me! sindicaci;ón

Saving local text files to S3 using paperclip

Sometimes you need to save a locally created file to S3 instead of an uploaded file, as is the standard. Here is how:

  has_attached_file :tagged_text_file,  STORAGE_OPTIONS.merge({
    :processors   => []
  })
  def save_tagged_text_file
    file = File.open("#{RAILS_ROOT}/tmp/tagged_text_#{id}.txt", 'w+')
    file << tagged_text
    self.tagged_text_file = file
    save!
    file.close
  end

Hinterlasse einen Kommentar