Skip to content

Commit

Permalink
Merge pull request #3373 from forbxy/fix-file-upload
Browse files Browse the repository at this point in the history
fix:when upload large file,we cant stop
  • Loading branch information
takluyver authored Mar 8, 2018
2 parents 290e574 + 191be80 commit c1c7d3d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions notebook/static/tree/js/notebooklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1220,12 +1220,14 @@ define([
NotebookList.prototype.add_large_file_upload_button = function (file) {
var that = this;
var item = that.new_item(0, true);
var stop_signal = false;
item.addClass('new-file');
that.add_name_input(file.name, item, 'file');
var cancel_button = $('<button/>').text("Cancel")
.addClass("btn btn-default btn-xs")
.click(function (e) {
item.remove();
stop_signal = true;
return false;
});

Expand All @@ -1250,7 +1252,7 @@ define([
if ($(v).data('name') === filename) { exists = true; return false; }
});
return exists
}
};
var exists = check_exist();

var add_uploading_button = function (f, item) {
Expand All @@ -1276,6 +1278,9 @@ define([
var upload_file = null;

var large_reader_onload = function (event) {
if (stop_signal === true) {
return;
}
if (event.target.error == null) {
offset += chunk_size;
if (offset >= f.size) {
Expand Down Expand Up @@ -1305,7 +1310,7 @@ define([
body : "Failed to read file '" + name + "'",
buttons : {'OK' : { 'class' : 'btn-primary' }}
});
}
};

chunk_reader = function (_offset, _f) {
var reader = new FileReader();
Expand Down Expand Up @@ -1363,7 +1368,7 @@ define([
}
};
that.contents.save(path, model).then(on_success, on_error);
}
};

// now let's start the read with the first block
chunk_reader(offset, f);
Expand Down

0 comments on commit c1c7d3d

Please sign in to comment.