All threads / How do i create a version carrierwave depending of file extention

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do i create a version carrierwave depending of file extention

Víctor Soto asked in Rails
Hi,

I trying to upload files with Carrierwave in my Rails app, files could be jpg, png, pdf or docx. Files jpg and png upload fine but pdf or docx don't, i get the error "...Minimagick, maybe it is not an image?", i read many forums and they say the error could be about the Carrierwave versions.

I  need to validate in the uploader that create version only when the file is an image jpg or png.

thanks.
Hey Victor,

The Carrierwave docs cover this here: https://github.com/carrierwaveuploader/carrierwave/wiki/how-to:-do-conditional-processing

You just want to check if it's an image before running the resizing and it's pretty easy to do. 👍
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 34,885+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.