oak-external-sdk/lib/service/qiniu/QiniuCloud.d.ts

243 lines
7.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Buffer } from 'buffer';
import { QiniuLiveStreamInfo, QiniuZone } from '../../types/Qiniu';
export declare class QiniuCloudInstance {
private accessKey;
private secretKey;
constructor(accessKey: string, secretKey: string);
/**
* 计算客户端上传七牛需要的凭证
* https://developer.qiniu.com/kodo/1312/upload
* @param bucket
* @param zone
* @param key
* @returns
*/
getKodoUploadInfo(bucket: string, zone: QiniuZone, key?: string): {
key: string | undefined;
uploadToken: string;
uploadHost: string;
bucket: string;
};
/**
* https://developer.qiniu.com/kodo/1308/stat
* 文档里写的是GET方法从nodejs-sdk里看是POST方法
*/
getKodoFileStat(bucket: string, zone: QiniuZone, key: string, mockData?: any): Promise<{
fsize: number;
hash: string;
mimeType: string;
type: 0 | 1 | 2 | 3;
putTime: number;
}>;
/**
* https://developer.qiniu.com/kodo/1257/delete
* @param bucket
* @param key
* @param mockData
* @returns
*/
removeKodoFile(bucket: string, zone: QiniuZone, key: string, mockData?: any): Promise<boolean>;
/**
* 列举kodo资源列表
* https://developer.qiniu.com/kodo/1284/list
* @param bucket
* @param marker
* @param limit
* @param prefix
* @param delimiter
* @param mockData
* @returns
*/
getKodoFileList(bucket: string, zone: QiniuZone, marker?: string, limit?: number, prefix?: string, delimiter?: string, mockData?: any): Promise<{
marker?: string;
items: Array<{
key: string;
hash: string;
fsize: number;
mimeType: string;
putTime: number;
type: number;
status: number;
}>;
}>;
moveKodoFile(srcBucket: string, zone: QiniuZone, srcKey: string, destBucket: string, destKey: string, force?: boolean, mockData?: any): Promise<void>;
copyKodoFile(srcBucket: string, zone: QiniuZone, srcKey: string, destBucket: string, destKey: string, force?: boolean, mockData?: any): Promise<void>;
/**
* 计算直播需要的token
* @param method
* @param path
* @param host
* @param rawQuery
* @param contentType
* @param bodyStr
* @returns
*/
getLiveToken(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, host: string, rawQuery?: string, contentType?: string, bodyStr?: string): string;
/**
* 创建直播流
* @param hub
* @param streamTitle
* @param host
* @param publishDomain
* @param playDomainType
* @param playDomain
* @param expireAt
* @param publishSecurity
* @param publishKey
* @param playKey
* @returns
*/
createLiveStream(hub: string, streamTitle: string, host: string, publishDomain: string, playDomainType: 'rtmp' | 'hls' | 'flv', playDomain: string, expireAt: number, publishSecurity: 'none' | 'static' | 'expiry' | 'expiry_sk', publishKey: string, playKey: string): Promise<{
streamTitle: string;
hub: string;
rtmpPushUrl: string;
playUrl: string;
pcPushUrl: string;
streamKey: string;
expireAt: number;
}>;
/**
* 计算直播流地址相关信息
* @param hub
* @param streamTitle
* @param expireAt
* @param publishDomain
* @param playDomainType
* @param playDomain
* @param publishSecurity
* @param publishKey
* @param playKey
* @returns
*/
getStreamObj(hub: string, streamTitle: string, expireAt: number, publishDomain: string, playDomainType: 'rtmp' | 'hls' | 'flv', playDomain: string, publishSecurity: 'none' | 'static' | 'expiry' | 'expiry_sk', publishKey: string, playKey: string): {
streamTitle: string;
hub: string;
rtmpPushUrl: string;
playUrl: string;
pcPushUrl: string;
streamKey: string;
expireAt: number;
};
getPlayBackUrl(hub: string, playBackDomain: string, streamTitle: string, start: number, end: number, method: 'GET' | 'POST' | 'PUT' | 'DELETE', host: string, rawQuery?: string): Promise<string>;
/**
* 禁用直播流
* @param hub
* @param streamTitle
* @param host
* @param disabledTill
* @param disablePeriodSecond
*/
disabledStream(hub: string, streamTitle: string, host: string, disabledTill: number, //禁播结束时间 -1永久禁播0解除禁播
disablePeriodSecond?: number): Promise<void>;
/**
* 查询直播流列表
* @param hub
* @param host
* @param liveOnly
* @param prefix
* @param limit
* @param marker
* @returns
*/
getLiveStreamList(hub: string, host: string, liveOnly?: boolean, prefix?: string, limit?: number, //取值范围0~5000
marker?: string): Promise<{
streamTitles: string[];
marker: string;
}>;
/**
* 查询直播流信息
* @param hub
* @param streamTitle
* @param host
* @returns
*/
getLiveStreamInfo(hub: string, streamTitle: string, host: string): Promise<QiniuLiveStreamInfo>;
/**
* 创建块(分片上传第一步)
* https://developer.qiniu.com/kodo/1286/mkblk
* @param zone 区域
* @param blockSize 块大小,单位字节
* @param firstChunkData 第一个分片的数据
* @param bucket 存储空间名称
* @returns
*/
mkblk(zone: QiniuZone, blockSize: number, firstChunkData: Buffer | Uint8Array, bucket: string): Promise<{
ctx: string;
checksum: string;
crc32: number;
offset: number;
host: string;
expired_at: number;
}>;
/**
* 上传分片数据(后续分片)
* https://developer.qiniu.com/kodo/1251/bput
* @param zone 区域
* @param ctx 前一次上传返回的块上下文
* @param offset 当前分片在块中的偏移量
* @param chunkData 分片数据
* @param bucket 存储空间名称
* @returns
*/
bput(zone: QiniuZone, ctx: string, offset: number, chunkData: Buffer | Uint8Array, bucket: string): Promise<{
ctx: string;
checksum: string;
crc32: number;
offset: number;
host: string;
expired_at: number;
}>;
/**
* 创建文件(合并所有块)
* https://developer.qiniu.com/kodo/1287/mkfile
* @param zone 区域
* @param fileSize 文件总大小,单位字节
* @param key 文件名
* @param bucket 存储空间名称
* @param ctxList 所有块的ctx列表按顺序排列
* @param mimeType 文件MIME类型
* @param fileName 原始文件名
* @returns
*/
mkfile(zone: QiniuZone, fileSize: number, key: string, bucket: string, ctxList: string[], mimeType?: string, fileName?: string): Promise<{
hash: string;
key: string;
}>;
/**
* 管理端访问七牛云服务器
* @param path
* @param method
* @param headers
* @param body
*/
private access;
/**
* https://developer.qiniu.com/kodo/1208/upload-token
* @param scope
* @returns
*/
private generateKodoUploadToken;
/**
* https://developer.qiniu.com/kodo/1201/access-token
*/
private generateKodoAccessToken;
private base64ToUrlSafe;
private hmacSha1;
private urlSafeBase64Encode;
/**
* 获取预签名对象URL统一接口
* 生成七牛云对象的访问/下载/上传URL
*
* 注意:七牛云下载需要使用存储桶绑定的域名,不能使用内网域名
* 上传使用表单方式,返回 formdata 中包含上传凭证
*/
presignObjectUrl(method: 'GET' | 'PUT' | 'POST' | 'DELETE', bucket: string, zone: QiniuZone, key: string, options?: {
expires?: number;
domain?: string;
}): Promise<{
url: string;
headers?: Record<string, string | string[]>;
formdata?: Record<string, any>;
}>;
}