많은 상호 작용이 있기 때문에 약간 배경이 있습니다. Fetcher를 통해 이메일을 가져와 MMS2R을 사용하여 첨부 파일을 추출합니다. 이 첨부 파일은 일반적으로 PDF 파일 또는 MS Word 문서가 될 것이므로 content-type
은 각각 application/pdf
및 application/msword
이 될 것으로 예상되지만 불행히도 많은 메일 프로그램이이를 수행하지 않는 것으로 보입니다.Paperclip과 Mimetype-fu를 통합하는 방법
대신 첨부 파일은 application/x-pdf
및 application/x-doc
입니다. scribd-fu가 문서를 제대로 iPaper 할 수 있도록 올바르게 설정해야합니다. 자, mimetype-fu는 적절한 content-type을 알아낼 수있을 것입니다. 그러나 저의 삶을 위해서, 저는 paperclip의 첨부 파일의 content-type을 올바르게 설정하는 방법을 알아낼 수 있습니다. 나는이 작업을 얻으려고 물건의 모든 방법을 시도 벽에 내 머리를 때리고했기 때문에,
mms.process do |media_type, files|
# go through each file
files.each do |filename|
# if it's a format we support, create a record
if media_type =~ /pdf/ # just pdfs for now, to reduce confusion
File.open(filename) do |tempfile|
# Somewhere in here I'd like to change filename.content_type
# to the proper type using mimetype-fu
# except doing tempfile.content_type = whatever doesn't seem to work.
thing = Thing.new
thing.document = tempfile
thing.save!
end
end
end
end
어떤 도움을 주시면 감사하겠습니다 :
다음은 코드의 조각입니다. 내가 성공하지 않거나 일 필요가 무엇 grokking없이 하나 이미 이러한 링크를 시도했다 :
- http://gist.github.com/55009/
- http://railsforum.com/viewtopic.php?id=27448
- http://github.com/dbackeus/paperclip/commit/a514bd03664fc6a764787f59c3169397336702b1
덕분에 크게!
이런. 때로는 문제를 해결하는 가장 간단한 방법입니다. 나는 왜 그것을 시도하지 않았는지 모르겠다! 감사! –