oss支持直接从客户端提交base64编码保存图片吗
Reoss支持直接从客户端提交base64编码保存图片吗
参考别人的代码,拼凑了一个方法,测试可用
// https://stackoverflow.com/questions/4998908/convert-data-uri-to-file-then-append-to-formdata// https://stackoverflow.com/questions/27553617/convert-blob-to-file// 转换图片 base64 => filefunction dataURItoFile(dataURI, fileName) { var byteString = atob(dataURI.split(',')[1]); var ab = new ArrayBuffer(byteString.length); var ia = new Uint8Array(ab); for (var i = 0; i ia = byteString.charCodeAt(i); } // return new Blob([ab], { type: 'image/jpeg' }); return new File([ia], fileName, {type: 'image/jpeg', lastModified: Date.now()})}
赞0
踩0