2015-04-20 27 views

回答

0

那麼,你正在運行Paperclip的文件類型驗證。顯然有很多不同的東西可以觸發這條信息。例如,如果您在Windows上運行,則必須manually install the file utility。截至版本4.0.0,every upload model needs to have a filetype validation of some sort, and has an un-removable validation to protect against filetype spoofing

我實際上並不知道您遇到了哪些問題,但是相同的鏈接爲每個解決方案提供瞭解決方案。 如果你沒有任何一種文件類型的驗證,你可能需要添加一些:

validates_attachment_file_name :column_name, :matches => [/apkg\Z/] 

,或者,如果不舒服安全意識:

do_not_validate_attachment_file_type :column_name 

對於第二個,好了,我只是要引用文檔:

[不可避免的欺騙檢查]有時會導致在使用自定義文件擴展名的應用程序中出現錯誤的驗證錯誤。在這些情況下,您可能希望你的 自定義擴展添加到文件擴展名的允許通過MIME類型的寶石配置您的MIME類型 名單:

# Allow ".foo" as an extension for files with the mime type "text/plain". 
text_plain = MIME::Types["text/plain"].first 
text_plain.extensions << "foo" 
MIME::Types.index_extensions text_plain