Created
March 2, 2017 19:32
-
-
Save danielpowell4/6c9f91d099a831048eee3311cec4e520 to your computer and use it in GitHub Desktop.
Verbose paperclip file extensions Basic: csv, pdf, txt | Microsoft: doc, docx, ppt, pptx, xls, xlsx | Images: gif, jpg, jpeg, png | Apple: pages, numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you want to add to your list, you can sniff using a binding.pry | |
# Look at the ActionDispatch::Http::UploadedFile object's Content-Type in the @header variable | |
validates_attachment :attachment, | |
allow_blank: false, | |
content_type: { content_type: ['image/jpg', #image | |
'image/jpeg', #image | |
'image/gif', #image | |
'image/png', #image | |
'application/pdf', #pdf | |
'application/msword', #word doc | |
'applicationvnd.ms-word', #word doc | |
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', #word docx | |
'application/msexcel', #excel xls | |
'application/vnd.ms-excel', #excel xls | |
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', #excel xlsx | |
'application/mspowerpoint', #powerpoint ppt | |
'application/vnd.ms-powerpoint', #powerpoint ppt | |
'application/vnd.openxmlformats-officedocument.presentationml.presentation', #powerpoint pptx | |
'application/x-iwork-pages-sffpages', #apple's pages | |
'application/x-iwork-keynote-sffnumbers', #apple's numbers | |
'text/plain', #txt | |
'text/csv'] }, # csv | |
file_name: { matches: [/csv\z/, | |
/docx?\z/, | |
/gif\z/, | |
/jpe?g\z/, | |
/numbers\z/, | |
/pages\z/, | |
/pdf\z/, | |
/png\z/, | |
/pptx?\z/, | |
/txt\z/, | |
/xlsx?\z/] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment