まず、多くのやり取りが行われているため、少し背景を説明します。Fetcherを介してメールを取得し、MMS2Rを使用してメールを処理して添付ファイルを抽出しています。これらの添付ファイルは通常、PDFファイルまたはMS Wordドキュメントになるため、それぞれcontent-type
とになるapplication/pdf
と予想されますapplication/msword
が、残念ながら、多くのメールプログラムではこれが行われていないようです。
application/x-pdf
代わりに、添付ファイルはとですapplication/x-doc
。scribd-fuがドキュメントを正しくiPaperできるように、これらを正しく設定する必要があります。これで、mimetype-fuは適切なコンテンツタイプを理解することができますが、私の人生では、クリップされた添付ファイルのコンテンツタイプを適切に設定する方法を理解することができます。
コードの抜粋は次のとおりです。
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
私はこれを機能させるためにあらゆる種類のことを試みて壁に頭を打ちつけてきたので、どんな助けもいただければ幸いです。私はこれらのリンクをすでに成功せずに、または何をする必要があるかを理解することなく試しました:
- http://gist.github.com/55009/
- http://railsforum.com/viewtopic.php?id=27448
- http://github.com/dbackeus/paperclip/commit/a514bd03664fc6a764787f59c3169397336702b1
どうもありがとうございました!