Pause and Resume #1070

Open
opened 2019-01-02 01:32:20 +00:00 by rahil471 · 1 comment
rahil471 commented 2019-01-02 01:32:20 +00:00 (Migrated from github.com)

Hi Guys, need some help.

I need to be able to pause and resume downloads. Can anyone guide me how this can be done?

Hi Guys, need some help. I need to be able to pause and resume downloads. Can anyone guide me how this can be done?
pelcomppl commented 2019-07-04 10:36:19 +00:00 (Migrated from github.com)

I not sure if it is what you exactly need, but this is my solution do some actions between files upload

this.uploader.onAfterAddingAll = fileItems => {
  this.uploadNextItem();
};

this.uploader.onCompleteItem = (
  file: FileItem,
  response: string,
  status: number,
  headers: ParsedResponseHeaders
) => {
  this.uploadNextItem();
  return { file, response, status, headers };
};

uploadNextItem() {
 const items = this.uploader.getNotUploadedItems().filter(f => !f.isError);
  if (items.length) {
    const item = items[0];
    this.service.doSth().subscribe(
      res => {
          item.upload();
      },
      err => {
          this.servicePNotify.error('Error!', err.error.message);
          this.uploadNextItem();
      }
    );
  }
}
I not sure if it is what you exactly need, but this is my solution do some actions between files upload ``` this.uploader.onAfterAddingAll = fileItems => { this.uploadNextItem(); }; this.uploader.onCompleteItem = ( file: FileItem, response: string, status: number, headers: ParsedResponseHeaders ) => { this.uploadNextItem(); return { file, response, status, headers }; }; uploadNextItem() { const items = this.uploader.getNotUploadedItems().filter(f => !f.isError); if (items.length) { const item = items[0]; this.service.doSth().subscribe( res => { item.upload(); }, err => { this.servicePNotify.error('Error!', err.error.message); this.uploadNextItem(); } ); } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#1070