提交 af628364 authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 f3e6a5da
import axios from 'axios'
import md5 from 'blueimp-md5'
import { getSignature, uploadFile } from '@/api/base'
export async function upload(blob: Blob) {
const key = 'upload/resource-center/' + md5(new Date().getTime() + Math.random().toString(36).slice(-8)) + '.png'
const fileType = blob.type.split('/').pop() || 'png'
const key = 'upload/resource-center/' + md5(new Date().getTime() + Math.random().toString(36).slice(-8)) + '.' + fileType
const response: any = await getSignature()
const params = {
key,
......@@ -17,3 +19,8 @@ export async function upload(blob: Blob) {
await uploadFile(params)
return params.url
}
export async function uploadFileByUrl(url: string) {
const res = await axios.get(url, { responseType: 'blob' })
return upload(res.data)
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论