Re: [CarrierWave] content_type after upload is empty

105 views
Skip to first unread message

Daniel Doubrovkine

unread,
Dec 2, 2012, 12:16:35 PM12/2/12
to carri...@googlegroups.com
I believe process :set_content_type needs the actual content-type.

process :set_content_type => 'image/jpeg'

You'll obviously either need to hardcode what content-type you want or figure it out programmatically, for example by doing a lookup with MIME::Types.type_for(filename)[0].

On Tue, Nov 27, 2012 at 8:10 AM, Daniel Lorenz <ext.my...@gmail.com> wrote:
Hi, I will programming an uploader for mp3- and ogg-files for a little project. In other projects I used paperclip but I will carrierwave give a try.
Creating an Uploader was very easy. Nice.

But the content_type is empty. When I uploaded any kind of file, I see the right content_type in the upload, but when I try to use the content_type, its empty.
Also the original_filename, but I only need the content_type for html5 audio type.

--- !ruby/object:CarrierWave::SanitizedFile file: .../public/uploads/audio/audio/19/test.ogg original_filename: content_type:    

I have the 'mime-types' gem installed an my uploader looks like this:
# encoding: utf-8
require 'carrierwave/processing/mime_types'
class AudioUploader < CarrierWave::Uploader::Base
  include CarrierWave::MimeTypes
  process :set_content_type
  storage :file
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end
end
Do I need anything else?

--
You received this message because you are subscribed to the Google Groups "carrierwave" group.
To view this discussion on the web visit https://groups.google.com/d/msg/carrierwave/-/DfIC_aV8sN0J.
To post to this group, send email to carri...@googlegroups.com.
To unsubscribe from this group, send email to carrierwave...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/carrierwave?hl=en.



--

dB. | Moscow - Geneva - Seattle - New York
dblock.org - @dblockdotorg


Reply all
Reply to author
Forward
0 new messages