添加了属性
This commit is contained in:
41
src/utils/vod.ts
Normal file
41
src/utils/vod.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { get } from '@/api/base'
|
||||
import TcVod from "vod-js-sdk-v6"
|
||||
|
||||
interface OnFunctio {
|
||||
(info: unknown): unknown;
|
||||
}
|
||||
|
||||
interface UploaderDone {
|
||||
fileId: string;
|
||||
video: {
|
||||
url: string;
|
||||
verify_content: string;
|
||||
}
|
||||
}
|
||||
|
||||
export async function uploadflie(file: File,on?: OnFunctio): Promise<UploaderDone> {
|
||||
const getSignature = () => {
|
||||
return new Promise<string>((res) => {
|
||||
get<string>('signature').then((data) => {
|
||||
console.log(data)
|
||||
res(data.data)
|
||||
})
|
||||
})
|
||||
}
|
||||
// const res = await get<string>('signature');
|
||||
// console.log(res.data)
|
||||
const tcVod = new TcVod({
|
||||
getSignature: getSignature
|
||||
})
|
||||
const uploader = tcVod.upload({
|
||||
mediaFile: file
|
||||
})
|
||||
if(on != undefined){
|
||||
uploader.on('media_progress', (info) => {
|
||||
on(info)
|
||||
})
|
||||
}
|
||||
const data = uploader.done();
|
||||
return data;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user