Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace filepath with key in callback request #165

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/assets/javascripts/s3_direct_upload.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ $.fn.S3Uploader = (options) ->
content = {}
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.key = $(result).find("Key").text()
else # IE <= 9 retu rn 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)
content.url = domain + $uploadForm.find('input[name=key]').val().replace('/${filename}', '') + encodeURIComponent('/' + file.name)
content.key = $uploadForm.find('input[name=key]').val().replace('/${filename}', '') + '/' + file.name;

content.filename = file.name
content.filesize = file.size if 'size' of file
Expand Down Expand Up @@ -170,4 +170,7 @@ $.fn.S3Uploader = (options) ->
@additional_data = (new_data) ->
settings.additional_data = new_data

@get_additional_data = () ->
settings.additional_data

@initialize()