javascript oss put base64 出现图片格式损坏
https://yq.aliyun.com/articles/253170?spm=5176.100240.searchblog.9.8tMWIb 参考这篇文章// Convert a base-64 string to a byte array base64ToBytes (base64) {
// Use browser-native function if it exists
if (typeof atob === 'function') return this.stringToBytes(window.atob(base64))
// Remove non-base-64 characters
base64 = base64.replace(/[^A-Z0-9+/]/ig, '')
var bytes = []
for (var i = 0; i >> 4))
break
case 2:
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & 0xF) >> 2))
break
case 3:
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & 0x3) 一定要转成base64ToBytes
赞0
踩1