zoukankan      html  css  js  c++  java
  • ant design upload 组件再限制只能上传 zip 时候出错问题 踩坑

     如下代码,再 没有 添加 file.type 类型为 "" 时候,上传 .zip文件再某些环境中会被拦截,提示' 请上传正确格式的附件!' 。这是 upload 对zip 的type分解时候分解为 “” 。因该分解为 ’application/x-zip-compressed‘,这个时候把 “” 也加进允许队列。还有一个.rar文件在上传的时候会被判定为 file.type = "" 。 所以说 upload 在有些环境可能把2这搞混乱了。

     const fileProps = {
                name: "multipartFile",
                listType: 'select',
                tipMsg: '支持扩展名:.zip,需包含excle和文件夹,仅允许上传一个文件',
                action: `${globalInitConfig.mdm_url}/mdm/api/innovation/patent/import_data`,
                onlySelectFile: true,
                beforeUpload(file) {
                    const isJPG = file.type === 'application/x-zip-compressed' || file.type == ""
                    if (!isJPG) {
                        Message.error('请上传正确格式的附件!');
                        return isJPG;
                    }
                    
                    if (_this.state.fileList.length > 0) {
                        Message.error('仅允许上传一个文件!');
                        return false;
                    }
                    _this.setState({
                        fileList: [file]
                    })
                },
  • 相关阅读:
    查看tls指纹
    并行流
    方法引入2
    方法引入
    Optional.ofNullable
    stream.filter
    stream.skip limit
    反射
    Optional orElseGet
    nginx 预压缩(gzip)
  • 原文地址:https://www.cnblogs.com/yeujuan/p/15693176.html
Copyright © 2011-2022 走看看