1

I am using paperclip to upload CSV files. I need to validate them, that only CSV files can be uploaded:

validates_attachment :uploaded_file_csv, content_type: { content_type: ['text/csv']} , message: "is not in CSV format"

But I have a problem with this validator: If user uploading file from Windows operation system or file was created by using Microsoft Office - this validator rising error that file is invalid. How to validate microsoft/csv files?

hhh_
  • 310
  • 2
  • 5
  • 17
arthur-net
  • 1,138
  • 1
  • 13
  • 34

1 Answers1

0

Add in the following content_type: application/vnd.ms-excel

The MIME type application/vnd.ms-excel is used to denote the presence of a Microsoft Excel spreadsheet or Microsoft Excel template. The category for this MIME type is "application". You should use "text/csv" according to RFC 4180.

Source

Community
  • 1
  • 1
Jason Brodie
  • 330
  • 5
  • 13