Taro: h5上传图片,文件名没有后缀,类型也不对。

Created on 14 Jun 2019  ·  5Comments  ·  Source: NervJS/taro

问题描述
image

复现步骤
用的Taro UI的ImagePicker组件
image

期望行为
image

系统信息
Taro CLI 1.3.0-beta.6 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.14.1 - D:\nodejs\node.EXE
Yarn: 1.12.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.9.0 - D:\nodejs\npm.CMD

question

Most helpful comment

需要自己根据mime type来生成个随机文件名。。。这个在微信群里有反馈过

具体要怎么操作?

import extName from 'ext-name';

          // TODO 现在 chooseImage 还不能返回完整的文件名,所以只能暂时这样fix

          try {
            const extInfo = extName.mime(tempFile.type);
            fileName = `temp.${extInfo[0].ext}`;
          } catch (e) {
            console.warn('error',e);
          }

All 5 comments

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

需要自己根据mime type来生成个随机文件名。。。这个在微信群里有反馈过

需要自己根据mime type来生成个随机文件名。。。这个在微信群里有反馈过

具体要怎么操作?

需要自己根据mime type来生成个随机文件名。。。这个在微信群里有反馈过

具体要怎么操作?

import extName from 'ext-name';

          // TODO 现在 chooseImage 还不能返回完整的文件名,所以只能暂时这样fix

          try {
            const extInfo = extName.mime(tempFile.type);
            fileName = `temp.${extInfo[0].ext}`;
          } catch (e) {
            console.warn('error',e);
          }

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

Was this page helpful?
0 / 5 - 0 ratings