tusen-ai / naive-ui

A Vue 3 Component Library. Fairly Complete. Theme Customizable. Uses TypeScript. Fast.

Home Page:https://www.naiveui.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: `n-upload` add file size limit

BobDu opened this issue · comments

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.

可以通过 on-before-upload 实现

ping @jahnli @jizai1125 是否有可能重新打开这个issue
考虑原生添加该属性去更开箱即用的提供上传文件大小限制功能?

没看到相关 api

  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;
  };