dwilkie/carrierwave_direct — pull request #58 by philipp-spiess (2013-01-11 15:12:23+00:00)
Title: Failure in Uploader.direct_fog_url

Hey!

I found a failure in the direct_fog_path [uplader.rb#L22-L31](https://github.com/dwilkie/carrierwave_direct/blob/master/lib/carrierwave_direct/uploader.rb#L22-L31)

The error is even located in the tests. A quick dump after this line [uploader_spec.rb#L244](https://github.com/dwilkie/carrierwave_direct/blob/master/spec/uploader_spec.rb#L244) and [uploader_spec.rb#L252](https://github.com/dwilkie/carrierwave_direct/blob/master/spec/uploader_spec.rb#L252) gave me the following results:

subject.direct_fog_url = https://s3.amazonaws.com/AWS_FOG_DIRECTORY/
subject.direct_fog_url(:with_path => true) = https://s3.amazonaws.com/upload_dir/some%20file%20&%20blah.exe

subject.direct_fog_url = https://s3.amazonaws.com/AWS_FOG_DIRECTORY/
subject.direct_fog_url(:with_path => true) = https://s3.amazonaws.com/upload_dir/bliind.exe`

It removes the AWS_FOG_DIRECTLY information from the URL and thus creating an invalid URL.

So i changed several things (including the tests) and voilà:

subject.direct_fog_url = https://s3.amazonaws.com/AWS_FOG_DIRECTORY/
subject.direct_fog_url(:with_path => true) = https://s3.amazonaws.com/AWS_FOG_DIRECTORY/upload_dir/some%20file%20&%20blah.exe

subject.direct_fog_url = https://s3.amazonaws.com/AWS_FOG_DIRECTORY/
subject.direct_fog_url(:with_path => true) = https://s3.amazonaws.com/AWS_FOG_DIRECTORY/upload_dir/bliind.exe`

And even if I set the config.fog_directory to something AWS "valid" (meaning including only numbers, letters and dashes), it will produce the right url an the tests will pass:

https://aws-fog.s3.amazonaws.com/upload_dir/bliind.exe