Seems like on chrome when cancel is hit in the file chooser, the 'changed' event is fired and startUpload() was being called. We need to check to see if the upload file is blank and - if so - just return immediately out of the function

This commit is contained in:
Chris Dodge
2013-06-11 13:38:01 -04:00
parent 673c015e8e
commit fa8ae228bf
2 changed files with 8 additions and 1 deletions

View File

@@ -103,6 +103,9 @@ def upload_asset(request, org, course, coursename):
logging.error('Could not find course' + location)
return HttpResponseBadRequest()
if 'file' not in request.FILES:
return HttpResponseBadRequest()
# compute a 'filename' which is similar to the location formatting, we're using the 'filename'
# nomenclature since we're using a FileSystem paradigm here. We're just imposing
# the Location string formatting expectations to keep things a bit more consistent

View File

@@ -411,8 +411,12 @@ function showFileSelectionMenu(e) {
}
function startUpload(e) {
file_input = $('.file-input').val().replace('C:\\fakepath\\', '');
if (file_input === '')
return;
$('.upload-modal h1').html(gettext('Uploading…'));
$('.upload-modal .file-name').html($('.file-input').val().replace('C:\\fakepath\\', ''));
$('.upload-modal .file-name').html(file_input);
$('.upload-modal .file-chooser').ajaxSubmit({
beforeSend: resetUploadBar,
uploadProgress: showUploadFeedback,