Forum: Ruby on Rails Paperclip: strange mime type on windows

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eff93e9bbe063b7136c9b6f218071a09?d=identicon&s=25 Marco Mastrodonato (marcomd)
on 2009-05-07 16:11
When i upload a pdf, validations doesn't work, only images validation
works. Avoiding check, file was loaded but with this content type:
file_content_type: "binary/octet-stream"

How can i solve? I'd like to have "application/pdf"
Eff93e9bbe063b7136c9b6f218071a09?d=identicon&s=25 Marco Mastrodonato (marcomd)
on 2009-05-07 16:46
I partially solved using this plugin to get correct mime from extension:
http://code.google.com/p/mimetype-fu/

And in my model i added:

  validate :validate_content_type

  protected

  def validate_content_type
    errors.add(:file, "Format #{File.mime_type?(file.path)} is
invalid!") unless File.mime_type?(file.path) == "application/pdf"
  end


If somebody want to get better this code will be appreciated
Thanks in any case
This topic is locked and can not be replied to.