Get content_type of uploaded file when using file-column

I use the file-column plugin to handle a file upload module for a rails
app. Plain and simple:

class Media < ActiveRecord::Base
file_column :file

What I now would like is to get the contetn_type or the IOString object
of the original uploaded file. file_column converts this to a string
object containing the path to the file.

Any idears?

You can’t determine that from the extension of the uploaded file?
What exactly are you trying to do?

You can try to override the file= method

alias_method :old_file=, :file=
def file=(original_io)
#do something with original io
old_file=(original_io)
end

kyle wrote:

You can’t determine that from the extension of the uploaded file?
What exactly are you trying to do?

You can try to override the file= method

alias_method :old_file=, :file=
def file=(original_io)
#do something with original io
old_file=(original_io)
end

I can’t make this work. File-column trabnsform the IO object to a String
object (the files location) This happens before I can get my hands on
the IOString object.

I could moove this to the controller but that feels like the wrong place
for this.

On 11/30/05, Mattias B. removed_email_address@domain.invalid wrote:

old_file=(original_io)
end

I can’t make this work. File-column trabnsform the IO object to a String
object (the files location) This happens before I can get my hands on
the IOString object.

I could moove this to the controller but that feels like the wrong place
for this.

I feel the same but now I couldn’t get the mime type from the model
declaration (ideally in a before_create hook). Then I wrote in some
controller:
def save
media = Media.new(params[:media])

media.content_type = params[:media][:file].content_type.strip
media.save
end