dwilkie / carrierwave_direct

Process your uploads in the background by uploading directly to S3
MIT License
839 stars 181 forks source link

Exception after uploading files with accented characters #165

Closed desheikh closed 9 years ago

desheikh commented 9 years ago

When uploading filenames with accented characters (é), attempting to modify the object with the attachment causes the following exception.

URI::InvalidURIError: URI must be ascii only

Heres part of the stack_trace 2.2.0/gems/carrierwave_direct-0.0.14/lib/carrierwave_direct/uploader.rb:64:in key' 2.2.0/gems/carrierwave_direct-0.0.14/lib/carrierwave_direct/uploader.rb:81:inhas_key?' 2.2.0/gems/carrierwave_direct-0.0.14/lib/carrierwave_direct/uploader.rb:94:in `filename'

This seems to be a problem with encoded_url only escaping certain characters. I'm not sure why we need to decode/encode the url again at all, since the url is already stored in encoded format and simply calling URI.parse url should just work.

def encoded_url
  URI.encode(URI.decode(url), " []+()")
end
arjan0307 commented 9 years ago

I have exactly the same problem with the included backtrace: https://gist.github.com/arjan0307/ed4d4521b8696f8f4605

It happens when an upload is attempted with the following parameters:

    "document_attributes": {
      "key": "uploads/documents/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/Overzicht zakelijke en privé kilometers.msg"

Mind the é in privé

arjan0307 commented 9 years ago

This seems to be one of the problems that https://github.com/dwilkie/carrierwave_direct/pull/120 fixes.

p8 commented 9 years ago

This should be fixed on master.

p8 commented 9 years ago

Closed because of inactivity.