2016-07-09 2 views
2

레일 클립 클립 프로세서를 사용하여 파워 포인트 프리젠 테이션 파일 및 기타 사무 관련 문서를 업로드하는 방법. 종이 클립 : 파워 포인트 프리젠 테이션 파일을 업로드하는 방법

다음은 내 코드입니다. 에서 mime_types.rb 내 모델에서

Mime::Type.register "application/vnd.openxmlformats-officedocument.wordprocessingml.document", :docx 
Mime::Type.register "application/vnd.openxmlformats-officedocument.presentationml.presentation", :pptx 
Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx 

asset.rb 나는이 오류 자산 첨부 파일 콘텐츠 유형을 수신하고

has_attached_file :attachment, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" 
validates_attachment_content_type :attachment, :content_type => ["application/pdf", "application/zip", "application/x-zip", "application/x-zip-compressed","application/octet-stream","image/jpg", "image/png", "image/jpeg", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"] 

이다 무효 자산 첨부 파일이 잘못

답변

2

아래로 더 MIME 형식을 병합 할 수 있습니다

Mime::Type.register "application/pdf", :pdf 
Mime::Type.register "application/xls", :xls 
Rack::Mime::MIME_TYPES.merge!({ 
    ".xls"  => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", 
    ".xlsx"  => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", 
    ".ppt"  => "application/vnd.openxmlformats-officedocument.presentationml.presentation", 
    ".pptx"  => "application/vnd.openxmlformats-officedocument.presentationml.presentation", 
    ".doc"  => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", 
    ".docx"  => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", 
})
2

pype에 대해이 MIME 유형으로 시도하십시오.

Mime::Type.register "application/vnd.openxmlformats-officedocument.presentationml.presentation", :pptx 

자세한 내용은 아래 링크를 참조하십시오.

https://technet.microsoft.com/en-us/library/ee309278(v=office.12).aspx

하고, 또한 당신은 당신의 mime_types.rb에서 모델

validates_attachment_content_type :attachment, :content_type => ["application/pdf", "application/zip", "application/x-zip", "application/x-zip-compressed","application/octet-stream","application/vnd.ms-office","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","image/jpg", "image/png", "image/jpeg"] 

에서

Rack::Mime::MIME_TYPES.merge!({ 
    ".pptx"  => "application/vnd.openxmlformats-officedocument.presentationml.presentation", 
    ".xlsx"  => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" 
})