ncuesta / dropzonejs-rails

Spice your Rails apps with some Dropzone sugar!
http://rubygems.org/gems/dropzonejs-rails
MIT License
311 stars 56 forks source link

Saving files with UTF-8 characters (e.g. japanese characters) #32

Closed kourindouhime closed 8 years ago

kourindouhime commented 8 years ago

Hi, when I try to upload file with a filename like 椎名林檎 蜜月抄 06 茜さす帰路照らされど….flac, it goes like this:

Processing by PetusharesController#create as JSON Parameters: {"utf8"=>"✓", "authenticity_token"=>"9K7GKDv3SlCOhQeHazhMj0SD6uHC2V76ou6yIF4jPSD7eQX0+9WhZ2enpvvtvQ8xyYP7/0K2pbWL3rSR9yiUqg==", "file"=>#<ActionDispatch::Http::UploadedFile:0x007fc23b5eb6e0 @tempfile=#<Tempfile:/var/folders/f9/79p7_5n163j55h1239qzx8fc0000gn/T/RackMultipart20160110-27556-74wf0m.flac>, @original_filename="椎名林檎 蜜月抄 06 茜さす帰路照らされど….flac", @content_type="audio/flac", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"\xE6\xA4\x8E\xE5\x90\x8D\xE6\x9E\x97\xE6\xAA\x8E \xE8\x9C\x9C\xE6\x9C\x88\xE6\x8A\x84 06 \xE8\x8C\x9C\xE3\x81\x95\xE3\x81\x99\xE5\xB8\xB0\xE8\xB7\xAF\xE7\x85\xA7\xE3\x82\x89\xE3\x81\x95\xE3\x82\x8C\xE3\x81\xA8\xE3\x82\x99\xE2\x80\xA6.flac\"\r\nContent-Type: audio/flac\r\n">} ActiveRecord::SessionStore::Session Load (0.2ms) SELECT "sessions".* FROM "sessions" WHERE "sessions"."session_id" = $1 ORDER BY "sessions"."id" ASC LIMIT 1 ["session_id", "51251de1c0d6f5bc7b0f36b5d3d536b2"] BEGIN SQL (0.4ms) INSERT INTO "petushares" ("file_name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" ["file_name", "06____.flac"], ["created_at", "2016-01-09 23:40:18.971199"], ["updated_at", "2016-01-09 23:40:18.971199"] COMMIT

So when I check the filename in DB, it says "06____.flac".

This is from my controller: Petushare.new(file_name: params[:file])

Can I do anything to enable utf-8? Thank you.

ncuesta commented 8 years ago

Hi, I haven't come across this situation, so I won't be of any help. Maybe you should try asking either on the dropzone repo or double checking your encoding configuration in both the form and the database. Sorry I can't help any further. Good luck!

Nahuel Cuesta Luengo On sáb, ene 9, 2016 at 20:45, ncuesta/dropzonejs-rails reply@reply.github.com wrote: Hi, when I try to upload file with a filename like 椎名林檎 蜜月抄 06 茜さす帰路照らされど…flac, it goes like this:

Processing by PetusharesController#create as JSON Parameters: {"utf8"=>"✓", "authenticity_token"=>"9K7GKDv3SlCOhQeHazhMj0SD6uHC2V76ou6yIF4jPSD7eQX0+9WhZ2enpvvtvQ8xyYP7/0K2pbWL3rSR9yiUqg==", "file"=>#, @original_filename="椎名林檎 蜜月抄 06 茜さす帰路照らされど…flac", @content_type="audio/flac", @headers [https://github.com/headers] ="Content-Disposition: form-data; name=\"file\"; filename=\"\xE6\xA4\x8E\xE5\x90\x8D\xE6\x9E\x97\xE6\xAA\x8E \xE8\x9C\x9C\xE6\x9C\x88\xE6\x8A\x84 06 \xE8\x8C\x9C\xE3\x81\x95\xE3\x81\x99\xE5\xB8\xB0\xE8\xB7\xAF\xE7\x85\xA7\xE3\x82\x89\xE3\x81\x95\xE3\x82\x8C\xE3\x81\xA8\xE3\x82\x99\xE2\x80\xA6flac\"\r\nContent-Type: audio/flac\r\n">} ActiveRecord::SessionStore::Session Load (02ms) SELECT "sessions"* FROM "sessions" WHERE "sessions""session_id" = $1 ORDER BY "sessions""id" ASC LIMIT 1 ["session_id", "51251de1c0d6f5bc7b0f36b5d3d536b2"] [http:01ms] BEGIN SQL (04ms) INSERT INTO "petushares" ("file_name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" ["file_name", "06____flac"], ["created_at", "2016-01-09 23:40:18971199"], ["updated_at", "2016-01-09 23:40:18971199"] [http:56ms] COMMIT

So when I check the filename in DB, it says "06____flac"

This is from my controller: Petusharenew(file_name: params[:file])

Can I do anything to enable utf-8? Thank you

— Reply to this email directly or view it on GitHub [https://github.com/ncuesta/dropzonejs-rails/issues/32] .[https://github.com/notifications/beacon/AAF1aHbzr8KXuLx7IeN75fhKOIzKst2hks5pYZM1gaJpZM4HByOq.gif]