Cancel file upload in one of the event methods? #505

Open
opened 2016-11-23 12:31:50 +00:00 by gmenih · 7 comments
gmenih commented 2016-11-23 12:31:50 +00:00 (Migrated from github.com)

Is there a way to cancel file upload in, say onAfterAddingFile? The documentation is very scarce.

// with autoUpload = true
onAfterAddingFile = (item: FileItem) => {
  item.cancel(); // doesn't work
  this.uploader.cancelItem(item); // doesn't work
  throw new Error(); // works
}
Is there a way to cancel file upload in, say `onAfterAddingFile`? The documentation is very scarce. ```javascript // with autoUpload = true onAfterAddingFile = (item: FileItem) => { item.cancel(); // doesn't work this.uploader.cancelItem(item); // doesn't work throw new Error(); // works } ```
bioform commented 2017-09-12 10:30:28 +00:00 (Migrated from github.com)

+1

+1
psagan commented 2018-01-21 12:22:47 +00:00 (Migrated from github.com)

I think it's working now. I'm using

item.cancel(); // where item is instance of FileItem

during upload and it's properly cancelled.

I think it's working now. I'm using ` item.cancel(); // where item is instance of FileItem ` during upload and it's properly cancelled.
frankforward commented 2018-01-30 10:15:40 +00:00 (Migrated from github.com)

@psagan which version of ng2-file-upload are you using. this is not working ofr me, i am using version 1.2.0 in angular2

@psagan which version of ng2-file-upload are you using. this is not working ofr me, i am using version 1.2.0 in angular2
psagan commented 2018-01-30 10:25:40 +00:00 (Migrated from github.com)

ng2-file-upload: version 1.2.1
Angular 4.4.6 with AngularCLI 1.5.4

ng2-file-upload: version 1.2.1 Angular 4.4.6 with AngularCLI 1.5.4
frankforward commented 2018-01-30 10:36:30 +00:00 (Migrated from github.com)

thanx @psagan, I have upgraded to that version,

"ng2-file-upload": "1.2.1",

and used

  onBeforeUploadItem = (fileItem: FileItem) => {
    fileItem.withCredentials = false;
    fileItem.cancel();
  };

still not working for me, the file is uploaded nonetheless

thanx @psagan, I have upgraded to that version, "ng2-file-upload": "1.2.1", and used onBeforeUploadItem = (fileItem: FileItem) => { fileItem.withCredentials = false; fileItem.cancel(); }; still not working for me, the file is uploaded nonetheless
dave0688 commented 2018-09-11 14:56:22 +00:00 (Migrated from github.com)

Same for me, I cannot cancel the upload. My version is: 1.3.0
I've tried it with:

item.cancel
this.uploader.cancelItem(item);

Can anybody help please?

Same for me, I cannot cancel the upload. My version is: 1.3.0 I've tried it with: ``` item.cancel this.uploader.cancelItem(item); ``` Can anybody help please?
NeelBhatt commented 2018-09-18 10:51:29 +00:00 (Migrated from github.com)

This works for me:

this.uploader.removeFromQueue(item);

This works for me: this.uploader.removeFromQueue(item);
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#505