We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/** * Base64编码转换成blob, (data:image/png;base64,xxxx) * @param {*} base64 * @return {*} */ export function base64ToBlob(base64) { const parts = base64.split(';base64,') const contentType = parts[0].split(':')[1] // image/png const raw = atob(parts[1]) // base64数据 const rawLength = raw.length const uInt8Array = new Uint8Array(rawLength) for (let i = 0; i < rawLength; ++i) { uInt8Array[i] = raw.charCodeAt(i) } const blobFile = new Blob([uInt8Array], { type: contentType, }) return new File([blobFile],`${new Date().getTime()}.${contentType.replace(/image\//g,'')}`,{ type: contentType, }) }
export function uploadImage(file) { const formData = new FormData() formData.append('file', file) formData.append('xxx', 'xxx') //接口入参 return request('xxxxx', formData) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
base64转文件流
文件流上传
The text was updated successfully, but these errors were encountered: