You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionblobToFile(blob: any,fileName: string){blob.lastModifiedDate=newDate();blob.name=fileName;returnblob;}asyncfunctiontransformFile(file: File): Promise<string|Blob|File>{// https://blog.csdn.net/qq_21937107/article/details/91424611// base64 to blob then fileconsole.log('file',file)try{constfileImg=awaitimageConversion.filetoDataURL(file)constblob=awaitimageConversion.dataURLtoFile(fileImg)constfileName=file.name.split('.')letfileType=fileName[fileName.length-1]// 如果文件类型是 jfif 使用 jpg 否则使用默认if(fileType==='jfif'){fileType='jpg'}constresult=blobToFile(blob,`${fileName[0]||Date.now()}.${fileType}`)console.log('result',result)returnresult}catch(e){console.log('e',e)returnfile}}
利用 imageConversion 逻辑就是 File transform base64 to blob then file
// to base64constfileImg=awaitimageConversion.filetoDataURL(file)// to blobconstblob=awaitimageConversion.dataURLtoFile(fileImg)// then fileblobToFile(blob,fileName)
JFIF上传成功包括WEBP IOS预览也正常
The text was updated successfully, but these errors were encountered:
2020-11-13 00:01:44
图片存储格式之一,由JPEG格式衍生而来,后缀为".jfif"。JFIF
了解到一种新的图片格式JFIF 但是这种图片格式上传是导致失败
Invalid filename
最后解决方案时候在前端上传的时候转换文件
如果没有图片的话可以在这里转换 https://convertio.co/zh/
前端:React Ant
后端:Nodejs Egg oss
前端用Ant的Upload https://ant.design/components/upload-cn/
这里有篇介绍格式转换的 https://blog.csdn.net/qq_21937107/article/details/91424611
利用 imageConversion 逻辑就是 File transform base64 to blob then file
JFIF上传成功包括WEBP IOS预览也正常
The text was updated successfully, but these errors were encountered: