2012-07-31 23 views
2

我見過很多這個錯誤的引用,但沒有一個與上傳有關,所以在這裏我在SO上看看是否有其他人看到了這個。Encoding :: CompatibilityError(不兼容的字符編碼:UTF-8和ASCII-8BIT) - 上傳文件到Heroku時

我對Heroku的cedar堆棧,一切都運行的應用程序去細,直到我有上傳與它UTF-8字符的文件,它只是失敗,下面的錯誤,我不知道發生了什麼或爲什麼,因爲表單主體 UTF-8(因爲Rails在所有表單上強制它)。

我有另一個應用程序,幾乎相同的事情,但沒有運行在接收帶有UTF-8字符的上傳的Heroku上運行文件。任何人都知道這可能是什麼,或者我可以如何解決它?

2012-07-31T17:43:59+00:00 app[web.1]: Started POST "/attachments" for 177.82.145.36 at 2012-07-31 17:43:59 +0000 
2012-07-31T17:43:59+00:00 app[web.1]: Processing by AttachmentsController#create as HTML 
2012-07-31T17:43:59+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"qhQ8bO/j6WFdu/AGLli6+KrXZPAsFfynwKBN6MqQt9Y=", "attachment"=>{"name"=>"JINGLE CUITÉ", "category_id"=>"8", "city_id"=>"8", "link"=>"", "assets_attributes"=>{"1"=>{"file"=>#<ActionDispatch::Http::UploadedFile:0x0000000504d7d8 @original_filename="Tárcio 40.mp3", @content_type="audio/mpeg", @headers="Content-Disposition: form-data; name=\"attachment[assets_attributes][1][file]\"; filename=\"T\xC3\xA1rcio 40.mp3\"\r\nContent-Type: audio/mpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20120731-2-1e58fuf>>}}, "description"=>""}, "commit"=>"Criar arquivo"} 
2012-07-31T17:43:59+00:00 app[web.1]: [paperclip] Saving attachments. 
2012-07-31T17:43:59+00:00 app[web.1]: [paperclip] saving attachments/2/original_Tárcio_40.mp3 
2012-07-31T17:44:00+00:00 app[web.1]: Completed 500 Internal Server Error in 393ms 
2012-07-31T17:44:00+00:00 app[web.1]: 
2012-07-31T17:44:00+00:00 app[web.1]: app/controllers/crud_controller.rb:20:in `create' 
2012-07-31T17:44:00+00:00 app[web.1]: Encoding::CompatibilityError (incompatible character encodings: UTF-8 and ASCII-8BIT): 
+0

名= \「T \ XC3 \ xA1rcio 40.mp3 \」 =>看起來它不喜歡的文件名。如果您重命名而沒有特殊字符,它會起作用嗎? – 2012-07-31 17:58:48

+0

這就是它被編碼爲通過網絡發送的方式,如果你看看'@ original_filename ='Tárcio40.mp3'',你會看到Rails似乎正確地理解了文件名。如果我將它更改爲沒有特殊字符的名稱,它可以正常工作。 – 2012-07-31 18:00:39

回答

相關問題