agora-edu-core-lb
Version:
For publishing npm package agora-edu-core (Web & Electron). Get more information from https://docs.agora.io
147 lines (146 loc) • 4.4 kB
TypeScript
import { CourseWareItem } from '../api/declare';
import { CourseWareUploadResult, CreateMaterialParams } from '../types';
import OSS from 'ali-oss';
import { ApiBase, ApiBaseInitializerParams } from './base';
export declare const mapFileType: (type: string) => any;
export declare type MaterialAccess = 'public' | 'private' | 'extra';
export declare type MaterialDataResource = {
id: string;
name: string;
ext: string;
type: string;
size: string | number;
taskUuid: string;
taskProgress: any;
url: string;
convertedPercentage?: number;
updateTime: number;
scenes?: any[];
access: MaterialAccess;
isActive?: boolean;
progress?: number;
};
export declare const transDataToResource: (data: CourseWareItem, access: MaterialAccess) => MaterialDataResource;
export interface UploadServiceResult {
success: boolean;
data: any;
message: string;
}
export declare type UploadConversionType = {
type: string;
preview: boolean;
scale: number;
outputFormat: string;
pack: boolean;
};
export declare type FetchStsTokenResult = {
bucketName: string;
callbackBody: string;
callbackContentType: string;
ossKey: string;
accessKeyId: string;
accessKeySecret: string;
securityToken: string;
ossEndpoint: string;
vendor: number;
preSignedUrl: string;
callbackHost: string;
};
export declare type HandleUploadType = {
file: File;
fileSize: number;
resourceUuid: string;
resourceName: string;
userUuid: string;
roomUuid: string;
ext: string;
conversion: any;
converting: boolean;
kind: any;
pptResult?: any;
onProgress: (evt: {
phase: string;
progress: number;
isTransFile?: boolean;
isLastProgress?: boolean;
}) => any;
};
export declare class UploadService extends ApiBase {
ossClient: OSS | null;
xhr: XMLHttpRequest;
abortCheckpoint: {
name?: string;
uploadId?: string;
};
constructor(params: ApiBaseInitializerParams);
region: string;
setRegion(region: string): void;
queryMaterial(params: {
name: string;
roomUuid: string;
}): Promise<UploadServiceResult>;
fetchStsToken(params: {
resourceUuid: string;
roomUuid: string;
resourceName: string;
ext: string;
fileSize: number;
conversion?: UploadConversionType;
}): Promise<{
success: boolean;
data: FetchStsTokenResult;
}>;
createMaterial(params: CreateMaterialParams): Promise<UploadServiceResult>;
fetchPublicResources(roomUuid: string): Promise<any>;
fetchPersonResources(roomUuid: string, userUuid: string): Promise<any>;
getFileInQueryMaterial(payload: {
roomUuid: string;
resourceName: string;
}): Promise<UploadServiceResult>;
handleUpload(payload: HandleUploadType): Promise<CourseWareUploadResult>;
handleUploadByAli(ossConfig: FetchStsTokenResult, payload: HandleUploadType): Promise<CourseWareUploadResult>;
handleUploadByAWS(ossConfig: FetchStsTokenResult, payload: HandleUploadType): Promise<CourseWareUploadResult>;
cancelFileUpload(): void;
get uploadCallbackPrefix(): string;
addFileToOss(ossClient: OSS, key: string, file: File, onProgress: CallableFunction, ossParams: any): Promise<any>;
addFileToAWS(file: File, onProgress: CallableFunction, ossParams: any): Promise<unknown>;
fetchImageInfo(file: File, x: number, y: number): Promise<void>;
private getImageSize;
removeMaterials(params: {
resourceUuids: string[];
roomUuid: string;
userUuid: string;
}): Promise<any>;
}
export declare type imageSize = {
width: number;
height: number;
};
export declare type PPTDataType = {
active: boolean;
pptType: PPTType;
id: string;
data: any;
cover?: any;
};
export declare enum PPTType {
dynamic = "dynamic",
static = "static",
init = "init"
}
export declare type NetlessImageFile = {
width: number;
height: number;
file: File;
coordinateX: number;
coordinateY: number;
};
export declare type TaskType = {
uuid: string;
imageFile: NetlessImageFile;
};
export declare type PPTProgressListener = (phase: PPTProgressPhase, percent: number) => void;
export declare enum PPTProgressPhase {
Uploading = 0,
Converting = 1
}