41 lines
946 B
TypeScript
41 lines
946 B
TypeScript
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;
|
|
|
|
} |