This repository was archived by the owner on Mar 14, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 234
This repository was archived by the owner on Mar 14, 2019. It is now read-only.
How to cancel upload queue ? #1038
Copy link
Copy link
Open
Description
Hello,
I have problems with cancelling file uploads.
Here is my helper button :
'click .btnCancel': function(e, instance) {
e.preventDefault();
if (FS.HTTP.uploadQueue.files && FS.HTTP.uploadQueue.files.attachments){
console.log("Queue is running : ", FS.HTTP.uploadQueue.isRunning()); //ok returns true;
const attachmentIdsOfFilesUploading = Object.keys(FS.HTTP.uploadQueue.files.attachments);
console.log("attachmentIdsOfFilesUploading : ", attachmentIdsOfFilesUploading); //return ["attachmentId1", "attachmentId2"]
FS.HTTP.uploadQueue.cancel();
console.log("Queue is running : ", FS.HTTP.uploadQueue.isRunning()); //ok return false;
Meteor.call("deleteAttachments", attachmentIdsOfFilesUploading, function(err){
//This performs Attachments.remove({'_id: {$in: ["attachmentId1", "attachmentId2"]}'})
if (err){
console.error(err); //Here we have error because collection FS is trying to remove the file (unlink) but as the file is not finished upladoed, it fails
toastr.error(err.reason);
return;
}
toastr.info(TAPi18n.__("Upload queue has been cancelled"));
window.location.reload(); //this is needed of collection FS crashes, the queue continue with some chunks...
});
}
},
Thanks if you guys know what to do.
Metadata
Metadata
Assignees
Labels
No labels