I have a pretty basic Paperclip Upload model that is attached to a User model through has_many, and am using Uploadify to do the actual uploading. Flash sends all files with the content type of "application/octet-stream" so using validates_attachment_content_type rejects all files.
In my create action, I am able to get the mime-type from the original file name, but only after it's been saved, with:
def coerce(params) h = Hash.new h[:upload] = Hash.new h[:upload][:attachment].content_type = MIME::Types.type_for(h[:upload][:attachment].original_filename).to_s ... end
and
def create diff_params = coerce(params) @upload = Upload.new(diff_params[:upload]) ... end
What would be the best way of white listing file types?
I am thinking a before_validation method, but I'm not sure how that would work. Any ideas would be welcome.