nzBeforeUpload from nz-upload should have the file parameter of type File instance instead of UploadFile
See original GitHub issueReproduction link
https://stackblitz.com/edit/ng-zorro-antd-start-ygithh?file=src/app/app.component.ts
Steps to reproduce
Use a nz-upload with a nzBeforeUpload attribute that returns false. Log the file parameter inside nzBeforeUpload.
What is expected?
I expect the argument type of the nzBeforeUpload function to be of type File instead of UploadFile as the function actually has inside Javascript
What is actually happening?
nzBeforeUpload has the wrong type definition for the file parameter of UploadFile instead of File.
| Environment | Info |
|---|---|
| ng-zorro-antd | 8.5.2 |
| Browser | * |
The type definition just needs to be changed to reflect what the function actually is called with: Now is:
nzBeforeUpload: (file: UploadFile, fileList: UploadFile[]) => boolean | Observable<boolean>;
It should be:
nzBeforeUpload: (file: File, fileList: File[]) => boolean | Observable<boolean>;
PS. I am not sure if the fileList parameter should be File[].
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:22 (5 by maintainers)
Top Results From Across the Web
Why nzBeforeUpload with option multiple is called multiple times
I'm using Angular 10 and ng-zorro and I am using nz-upload component, and I have a question: Why beforeUpload is called equal to...
Read more >Upload | NG-ZORRO - Ant Design
Uploading is publishing information (web pages, text, pictures, video, etc.) to a remote server via a web page or upload tool. When you...
Read more >File upload | NestJS - A progressive Node.js framework
To handle file uploading, Nest provides a built-in module based on the multer ... For this, you can create your own Pipe and...
Read more >Request Files - FastAPI
Define a file parameter with a type of UploadFile : ... as the request will have the body encoded using multipart/form-data instead of...
Read more >Upload file data | Google Drive
Simple upload ( uploadType=media )—Use this upload type to transfer a small media file (5 MB or less) without supplying metadata. To perform...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Still broken in version 13. 😮
I have exactly same case like @emondora. For now i use a small workaround: In my
beforeUploadfunction i accept file as UploadFile:but later i’m just casting types: