Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
Retrieve file from S3. - Carrierwave Rails Gem

I'm implementing Carrierwave with fog storage into my Rails App. The whole purpose of this app is to store pdf articles and have the ability for anyone with access to the app to retrieve them. Right now, I have the functionality of storing the article pdf working great. But, now I need to be able to retrieve the pdf from S3. Is this possible? I noticed in the docs there is a uploader.retrieve_from_store!("my_file.png") method. I tried to run this in the console and I got this error NoMethodError: undefined method retrieve_from_store! for ArticleUploader:Class Any help with this would be great! I'm just not finding any suitable answers so far. Thanks!

Article Uploader

class ArticleUploader < CarrierWave::Uploader::Base

  storage :fog

  def extension_whitelist
    %w(jpg jpeg gif png pdf)
  end

end

Article Model

class Article < ApplicationRecord
  mount_uploader :file, ArticleUploader
  validates :title, presence: :true
  validates :publication_date, presence: :true
  validates :source, presence: :true
end
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can access it with the methods that carrierwave has, in your case:

article = Article.find(1)
article.file.url

If you are on development it will output the path for the file and if you are on production and using S3, it will output the whole url, http://s3.amazonaws.com/<vendor>/articles/1/file.pdf for example.

You can find more information on the official docs:

https://github.com/carrierwaveuploader/carrierwave#activerecord

There is also an old rails cast on that http://railscasts.com/episodes/253-carrierwave-file-uploads

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!