Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda