Mark Robinson
Mark Robinson

Reputation: 1629

Can I validate that a paperclip attachment is not a dangerous filetype?

I'm using thoughtbot's paperclip with Rails and want to allow any file type to be uploaded except one that's obviously dangerous. The validates_attachment_content_type method makes it easy to validate that an attachment is of a safe type but is it possible to just validate it's not dangerous?

Upvotes: 2

Views: 865

Answers (1)

trh
trh

Reputation: 7339

Yes there is.

validates_attachment :image, :content_type => { :not => "application/zip" }

That would let you use the notion of blacklisting instead of whitelisting.

Upvotes: 2

Related Questions