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

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Marco M. (Guest)
on 2009-05-07 18: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"
Marco M. (Guest)
on 2009-05-07 18:46
I partially solved using this plugin to get correct mime from extension:

And in my model i added:

  validate :validate_content_type


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

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.