angular-material-fileupload
angular-material-fileupload copied to clipboard
Callback function??
Maybe I missed it, but is there a callback function when a file has successfully uploaded?
i am also looking for callback to get the service response after upload.
There is the possibility to attach to (onUpload)
in your component:
<mat-file-upload [file]="file"
[id]="i" *ngFor="let file of fileUploadQueue.files; let i = index"
(onUpload)="fileUploaded($event)"></mat-file-upload>```
In the component you can start with a function like this:
export class MyComponent {
// Catches upload start, upload progress and completed events
fileUploaded(event) {
const serverEvent = event.event;
const file: File = event.file;
// If the event has a body the upload should be complete
// and the body is your server JSON response. You can
// fire a new event when this happens and pass the server response
// on to others components.
if (serverEvent.body) {
console.log(event);
}
}
}
Would probably be good to add something like this to the docs.
Thanks for the reply.
i was already implemented in the same manner.
On Tue, May 28, 2019 at 6:41 PM Tobias Schönberg [email protected] wrote:
There is the possibility to attach to (onUpload) in your component:
<mat-file-upload [file]="file" [id]="i" *ngFor="let file of fileUploadQueue.files; let i = index" (onUpload)="fileUploaded($event)">```
In the component you can start with a function like this:
export class MyComponent { // Catches upload start, upload progress and completed events fileUploaded(event) { const serverEvent = event.event; const file: File = event.file;
// If the event has a body the upload should be complete // and the body is your server JSON response. You can // fire a new event when this happens and pass the server response // on to others components. if (serverEvent.body) { console.log(event); } }
}
Would probably be good to add something like this to the docs.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nishantmc/angular-material-fileupload/issues/46?email_source=notifications&email_token=AAGZ7CBDRTOR7HZX6XP4653PXUVPVA5CNFSM4HC24NCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWMCIFQ#issuecomment-496509974, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGZ7CDRBJMFWEKGKASLFT3PXUVPVANCNFSM4HC24NCA .
--
Thanks & Regards,
Mayank Jindal