Skip to content
This repository was archived by the owner on Mar 14, 2019. It is now read-only.
This repository was archived by the owner on Mar 14, 2019. It is now read-only.

How to cancel upload queue ? #1038

@dokithonon

Description

@dokithonon

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions