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

bug fixes

上级 af628364
...@@ -2,9 +2,21 @@ import axios from 'axios' ...@@ -2,9 +2,21 @@ import axios from 'axios'
import md5 from 'blueimp-md5' import md5 from 'blueimp-md5'
import { getSignature, uploadFile } from '@/api/base' import { getSignature, uploadFile } from '@/api/base'
export async function upload(blob: Blob) { export async function upload(blob: Blob | File) {
const fileType = blob.type.split('/').pop() || 'png' let fileType = 'png'
const key = 'upload/resource-center/' + md5(new Date().getTime() + Math.random().toString(36).slice(-8)) + '.' + fileType if (blob instanceof File && blob.name) {
const matches = blob.name.match(/\.(\w+)$/)
if (matches) {
fileType = matches[1]
}
} else if (blob.type) {
const mimeType = blob.type.split('/').pop()
if (mimeType) {
fileType = mimeType
}
}
const key =
'upload/resource-center/' + md5(new Date().getTime() + Math.random().toString(36).slice(-8)) + '.' + fileType
const response: any = await getSignature() const response: any = await getSignature()
const params = { const params = {
key, key,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论