Skip to content

Commit

Permalink
Fix for spaces in urls
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmurphy committed May 29, 2013
1 parent d647ad2 commit 3e27133
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/assets/javascripts/s3_direct_upload.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ $.fn.S3Uploader = (options) ->

build_content_object = ($uploadForm, file, result) ->
content = {}
domain = $uploadForm.attr('action')
if result # Use the S3 response to set the URL to avoid character encodings bugs
content.url = $(result).find("Location").text()
content.filepath = $('<a />').attr('href', content.url)[0].pathname
content.filepath = $(result).find("Key").text()
pathname = $('<a />').attr('href', content.filepath)[0].pathname
content.url = domain + pathname
else # IE <= 9 return a null result object so we use the file object instead
domain = $uploadForm.attr('action')
content.filepath = $uploadForm.find('input[name=key]').val().replace('/${filename}', '')
content.url = domain + content.filepath + '/' + encodeURIComponent(file.name)

Expand Down

0 comments on commit 3e27133

Please sign in to comment.