Feature Request: `n-upload` add file size limit
BobDu opened this issue · comments
Bob Du commented
Clear and concise description of the problem
We can easy limit user upload file size.
Suggested solution
Add a props size-limit
for <n-upload>
component.
Alternative
No response
Additional context
No response
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
吉仔 commented
可以通过 on-before-upload
实现
Bob Du commented
ping @jahnli @jizai1125 是否有可能重新打开这个issue
考虑原生添加该属性去更开箱即用的提供上传文件大小限制功能?
jahnli commented
没看到相关 api
jahnli commented
const beforeUpload = ({ file }: { file: UploadFileInfo; fileList: UploadFileInfo[] }) => {
const fileSize = parseFloat(((file.file?.size ?? 0) / 1024 / 1024).toFixed(1));
if (fileSize > astrictFileSize) {
return false;
}
return true;
};