question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nzBeforeUpload from nz-upload should have the file parameter of type File instance instead of UploadFile

See original GitHub issue

Reproduction 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:open
  • Created 4 years ago
  • Reactions:4
  • Comments:22 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
krokofantcommented, Jan 19, 2022

Still broken in version 13. 😮

4reactions
adammrukcommented, Jun 16, 2020

I have exactly same case like @emondora. For now i use a small workaround: In my beforeUpload function i accept file as UploadFile:

beforeUpload = (file: UploadFile): Observable<boolean> => {

but later i’m just casting types:

reader.readAsDataURL(file as unknown as File);
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found