npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wlite-avsdk-vod-upload-node-v2

v2.0.6

Published

new start

Readme

旺链VOD上传sdk -node.js

pakcagename: wlite-avsdk-upload-download-node,
vesion: v2.0.0

安装方法

npm

npm i wlite-avsdk-upload-download-node

yarn

yarn add wlite-avsdk-upload-download-node

导入库方法(仅供参考,请保证对象只初始化一次)

第一种

const pu = require('wlite-avsdk-upload-download-node');
使用方法
let publish = new pu.default()
    .withAppServerUrl(url)
    .withToken(token)
    .withFFmpeg(ffmpegPath);

第二种

import pu2 from 'wlite-avsdk-upload-download-node';
使用方法
let publish = pu2.prototype
    .withToken(token)
    .withFFmpeg(ffmpegPath)
    .withAppServerUrl(url);

加密Result参数

/** 加密返回结果内容 */
export interface CryptContentResult{
/** 用于解密都文件大小(IOS,android) */
fileSize: number;
/** AES+MAC对称密钥 */
key: string; /* 注意 16进制 */
/** 摘要 */
digest?: string; /* 注意 16进制 */
}

加密Result视频(设置为不加密的情况下返回的加密信息不存在)

export interface VideoComplete extends UploadComplete {
/** id, equals MediaID */
id: string;
/** 带签名的视频链接,一个小时后过期,过期后需要使用id重新申请url */
url: string;
/** 封面链接,无需签名 */
cover: string;
/** 上传时传递的参数,标识当前上传任务 */
mark: string;
/** 视频时长 */
duration: number;
/** 文件大小 bytes */
filesize: number;
/** 分辨率 */
width: number;
height: number;
/** 加密信息(当设置加密时返回) */
cryptInfo?: CryptContentResult;
cryptInfoCover?: CryptContentResult;
}

加密Result图片(设置为不加密的情况下返回的加密信息不存在)

export interface ImageComplete extends UploadComplete {
/** 图片分辨率名称 */
name: string;
/** id, equals MediaId */
id: string;
/** 可以直接访问的链接 */
url: string;
/** 上传时传递的参数,标识当前上传任务 */
mark: string;
/** 图片宽度 */
width: number;
/** 图片高度 */
height: number;
/** 文件大小 */
filesize: number;
/** 加密信息(当设置加密时返回) */
cryptInfo?: CryptContentResult;
}

加密Result文件(设置为不加密的情况下返回的加密信息不存在)

export interface FileComplete extends UploadComplete {
/** id, equals MediaID */
id: string;
/** 可直接访问的链接 */
url: string;
/** 文件大小 */
filesize: number;
/** 上传时传递的参数,标识当前上传任务 */
mark: string;
/** 加密信息(当设置加密时返回) */
cryptInfo?: CryptContentResult;
}

输入参数

/** 视频发布参数 */
export interface VideoPublishParam {
/** 视频文件路径 */
video: string;// Buffer|Uint8Array|Blob|string|Readable;
/** 封面图片路径 */
cover?: string; // Buffer|Uint8Array|Blob|string|Readable;
/** 标记 */
mark: string;
/** 是否加密 */
encrypt?: boolean;
/** 存储时间 单位秒, -1:永不过期, 0:7天 , 默认-1*/
duration?: number;
}

export const enum ImagePublishUsage {
Headshot = 0,       // 头像
Figure,         // 插图
Meme            // 表情包
}

/** 图片发布参数定义 */
export class ImagePublishParam {
constructor(file: string, mark: string) {
// 默认分辨率
this.resolutions = [
//{name: 'Original', quality: 100},
{ name: 'High', quality: 90, scale: 1.0 },
{ name: 'Medium', quality: 80, scale: 0.5 },
{ name: 'Low', quality: 80, scale: 0.2 }
]
// 默认标签
this.tag = { key: 'public', value: '1' };

        this.file = file;
        this.mark = mark;
        this.duration = -1;
    }
    /** 图片文件路径 */
    public file: string;// Buffer|Uint8Array|Blob|string|Readable;
    /** 标签 */
    public tag: Tag;
    /** 标识 */
    public mark: string;
    /** 多分辨率 */
    public resolutions: Array<Resolution>;
    /** 是否加密 */
    public encrypt?: boolean;
    /** 存储时间 单位秒, -1:永不过期, 0:7天 , 默认-1*/
    public duration?: number;
    /** 图片用途, 默认表情 */
    public usage: ImagePublishUsage = ImagePublishUsage.Meme;
}

export interface FilePublishParam {
/** 本地路径 */
file: string;
/** 标识 */
mark: string;
/** 是否加密 */
encrypt?: boolean;
/** 存储时间 单位秒, -1:永不过期, 0:7天 , 默认-1*/
duration?: number;
}

/** 标签键值对 */
export interface Tag {
key: string;
value: string;
}

/** 分辨率参数 */
export interface Resolution {
/** 分辨率名称 */
name: string;
/** 压缩质量 0~100 */
quality: number;
/**
* 缩放比例 0.0f ~ 1.0f
* @remartk
*/
scale?: number;
/**
* 固定高度
* @remark scale未定义的时候,height参数生效
*/
height?: number;
}

新接口使用案例(更多返回参数请参考result)


function V2main() {
    let token = "eyJhbGciOiJIUzUxMiJ9.eyJhdWQiOiJudWxsIiwiaGVhZEltZyI6Imh0dHBzOi8vb3NzLmRpZGltZXNzYWdlLmNvbS9pbWFnZXMvMjAyMC8xMS8yMy9hNjliYjA1ZS0wNTBhLTRjNjctODk4OC0zYjc5M2IwMTlmZmFfMTAwOHgxMDA4LmpwZyIsIm5pY2tOYW1lIjoi5bqZ6KGM55S15a2Q5ZWG5Yqh56S66IyD5Z-65Zyw5L-d5a6J5p2O5aSn54i3IiwiY291bnRyeUNvZGUiOm51bGwsImludml0ZUNvZGUiOiIxMDEzMzc5OCIsInNleCI6MSwiaXNzIjoiMTA4ODY1OTc3OTA3MDE0NDUxMiIsInVzZXJUeXBlIjowLCJleHAiOjQxOTk2NzIyODEsImlhdCI6MTYwNzY3MjI4MSwiZW1haWwiOm51bGwsImp0aSI6IjcyNWU0ZTFiLTdmM2MtNDlmYi04MTgzLTdjN2Y3NTBjODQzZSJ9.Y_VuAaA5ofWTWA9tu29edR-W7_NoXaWl_cxEje0iRGXQ8TRwvndp7hfmU60RI_w8s9N4xi8kJfOLrieCB5U_cA";
    let ffmpegPath = '/Users/macos/Desktop/Documents/ffmpeg-mac';

    /**
     * @breif 初始化对象接口
     * @function withAppServerUrl()
     * @param url 服务器路径
     * @function withToken()
     * @param token 令牌
     * @function withFFmpeg()
     * @param ffmpegPath ffmpeg路径
     * @return publish 对象接口
     */
    let publish = new pu.default()
        .withAppServerUrl('https://test500.zhidianjh.com:8228/') //服务器地址
        .withToken(token)
        .withFFmpeg(ffmpegPath);

    /**
     * V1兼容接口
     * publish.PublishFileAsync(param.encrypt = true) ==PublishCryptFileAsync()
     */
    publish.PublishFileAsync({
        file: '/Users/macos/Desktop/Documents/data.txt',
        mark: 'fileme',
        encrypt: true
    });
    /**
     * V2接口信息
     * @breif 上传加密文件
     * @param file 文件路径
     * @param mark 文件标识
     * @return progress 回调函数 用来监控上传进度
     * @return ret 返回的所有参数信息
     * */
    publish.PublishCryptFileAsync({
        file: '/Users/macos/Desktop/Documents/data.txt',
        mark: 'fileme'
    }, progress => {
        //进度监控
        console.log(progress.Uploaded / progress.Total);
    })
        .then(ret => {
            console.log("id-----" + ret.id);
            console.log("mark---" + ret.mark);
            console.log("size---" + ret.filesize);
            console.log("url----" + ret.url);
        })
        .catch(e => {
            console.error(e);
        })

    /**
     * V1兼容接口
     * publish.PublishVideoAsync(param.encrypt = true) == PublishCryptVideoAsync()
     */
    publish.PublishVideoAsync({
        file: '/Users/macos/Desktop/Documents/data.txt',
        mark: 'fileme',
        encrypt: true
    });
    /**
     * @breif 上传加密视频
     * @param video 视频路径
     * @param mark 文件标示
     * @return progress 回调函数 用来监控上传进度
     * @return ret 返回的所有参数信息
     */
    publish.PushlishCryptVideoAsync({
        video: 'D:\\UserData\\Video\\13464003121845cd7ab6001.mp4',
        mark: 'fdf'
    }, progress => {
        //进度监控
        console.log(`total--${progress.Total} progress--${progress.Uploaded / progress.Total}`);
    })
        .then(ret => {
            console.log('url:' + ret.url);
            console.log('id:' + ret.id);
            console.log('cover:' + ret.cover);
        })
        .catch(e => {
            console.error(e);
        })


    /**
     * V1兼容接口
     * publish.publishImageAsync(param.encrypt = true) == PublishCryptImageAsync()
     * V2修订格式错误(保留原有接口 都可以使用)
     * publish.PublishImageAsync(param.encrypt = true) == PublishCryptImageAsync()
     */
    let param = new pu.ImagePublishParam(
        "/Users/macos/Desktop/Documents/timg.png",
        'mark'
    );
    param.usage = 0;
    param.duration = -1;
    param.resolutions = [
        {name: 'High', quality: 92, height: 200},
        {name: 'Low', quality: 80, scale: 0.3}
    ];
    param.encrypt = true;
    publish.PublishCryptImageAsync(param, progress => {
        ;
    })
    /**
     * @breif 上传头像
     * @param ImagePublishParam(文件路径,文件标识)
     * @param usage 上传类型
     * @param duration 存储时间长度
     * @param resolutions 设置分辨率以及压缩比例
     * @return progress 回调函数 用来监控上传进度
     * @return ret 返回的所有参数信息
     */
    let param1 = new pu.ImagePublishParam(
        "/Users/macos/Desktop/Documents/timg.png",
        'mark'
    );
    param1.usage = 0;
    param1.duration = -1;
    param1.resolutions = [
        {name: 'High', quality: 92, height: 200},
        {name: 'Low', quality: 80, scale: 0.3}
    ];
    publish.PublishCryptImageAsync(param1, progress => {
       ;
    })
        .then(ret => {
            for (let img of ret) {
                console.log(`${img.name}: ${img.url}`);
            }
        })
        .catch(e => {
            console.error(e);
        })

    /**
     * @breif 上传表情
     * @param ImagePublishParam(文件路径,文件标识)
     * @param usage 上传类型
     * @param duration 存储时间长度
     * @param resolutions 设置分辨率以及压缩比例
     * @return progress 回调函数 用来监控上传进度
     * @return ret 返回的所有参数信息
     */
    let param2 = new pu.ImagePublishParam(
        "/Users/macos/Desktop/Documents/timg.png",
        'mark2'
    );
    param2.usage = 2;
    param2.duration = 0;
    publish.PublishCryptImageAsync(param2, progress => {
        ;
    }).then(ret => {
        for (let img of ret) {
            console.log(`${img.name}: ${img.url}`);
        }
    })

    /**
     * @breif 上传插图
     * @param ImagePublishParam(文件路径,文件标识)
     * @param usage 上传类型
     * @param duration 存储时间长度
     * @param resolutions 设置分辨率以及压缩比例
     * @return progress 回调函数 用来监控进度
     * @return ret 返回的所有参数信息
     */
    let param3 = new pu.ImagePublishParam(
        "/Users/macos/Desktop/Documents/timg.png",
        'mark3'
    );
    param3.usage = 1;
    publish.PublishCryptImageAsync(param2, progress => {
        ;
    }).then(ret => {
        for (let img of ret) {
            console.log(`${img.name}: ${img.url}`);
        }
    })

    /**
     * @breif 聊天上传原图(png, gif等)
     * @param ImagePublishParam(文件路径,文件标识)
     * @param usage 上传类型
     * @param duration 存储时间长度
     * @param resolutions 设置分辨率以及压缩比例
     * @return progress 回调函数 用来监控进度
     * @return ret 返回的所有参数信息
     */
    let param4 = new pu.ImagePublishParam(
        "/Users/macos/Desktop/Documents/timg.png",
        'mark3'
    );
    param4.usage = 2;
    param4.resolutions = [
        {name: 'Original', quality: 100},
        {name: 'High', quality: 90, scale: 0.8}
    ];
    publish.PublishCryptImageAsync(param4, progress => {
        ;
    }).then(ret => {
        for (let img of ret) console.log(`${img.name}: ${img.url}`);
    });

    /**
     * @breif 通过网络URL解密接口
     * @param path: string,
     * @param key: string;             //,密钥(16进制字符串)
     * @param digest: string;          //,摘要(16进制字符串)
     */
    publish.PublishPathDecrypt(
        "url信息",
        "key信息",
        "digest信息",
    );


    /***
     * @breif 加密返回对象
     * @param EnctyptObject{
     *      ciphertext: ArrayBuffer; //密文对象
     *      key: Uint8Array(64) 
     *      digest: ArrayBuffer(32)
     *  }
     */
    publish.PublishBufferDecrypt({
        ciphertext: "",
        key: "",
        digest: "",
    });
}

旧接口使用案例

function V1main() {
    /**
     * token
     **/
    let token = "eyJhbGciOiJIUzUxMiJ9.eyJhdWQiOiJudWxsIiwiaGVhZEltZyI6Imh0dHBzOi8vb3NzLmRpZGltZXNzYWdlLmNvbS9pbWFnZXMvMjAyMC8xMS8yMy9hNjliYjA1ZS0wNTBhLTRjNjctODk4OC0zYjc5M2IwMTlmZmFfMTAwOHgxMDA4LmpwZyIsIm5pY2tOYW1lIjoi5bqZ6KGM55S15a2Q5ZWG5Yqh56S66IyD5Z-65Zyw5L-d5a6J5p2O5aSn54i3IiwiY291bnRyeUNvZGUiOm51bGwsImludml0ZUNvZGUiOiIxMDEzMzc5OCIsInNleCI6MSwiaXNzIjoiMTA4ODY1OTc3OTA3MDE0NDUxMiIsInVzZXJUeXBlIjowLCJleHAiOjQxOTk2NzIyODEsImlhdCI6MTYwNzY3MjI4MSwiZW1haWwiOm51bGwsImp0aSI6IjcyNWU0ZTFiLTdmM2MtNDlmYi04MTgzLTdjN2Y3NTBjODQzZSJ9.Y_VuAaA5ofWTWA9tu29edR-W7_NoXaWl_cxEje0iRGXQ8TRwvndp7hfmU60RI_w8s9N4xi8kJfOLrieCB5U_cA";
    /**
     * url 服务器链接
     */
    let url = 'https://test500.zhidianjh.com:8228/';
    /**
     * ffmpath 路径
     */
    let ffmpegPath = 'D:\\UserData\\Document\\Tools\\ffmpeg release\\ffmpeg-4.3.1-win64-static\\bin\\ffmpeg.exe';

    /**
     * 初始化接口
     */
    let publish = new pu.default()
        .withAppServerUrl(url)
        .withToken(token)
        .withFFmpeg(ffmpegPath);

    /**
     * 上传文件
     * @param file 文件路径
     * @param mark 文件标识
     * @return progress 回调函数 用来监控上传进度
     * @return ret 返回的所有参数信息
     */
    publish.PublishFileAsync({
        file: "fileurl",
        mark: 'fileme'
    }, progress => {
        console.log(progress.Uploaded / progress.Total);
    })
        .then(ret => {
            console.log("id-----" + ret.id);
            console.log("mark---" + ret.mark);
            console.log("size---" + ret.filesize);
            console.log("url----" + ret.url);
        })
        .catch(e => {
            console.error(e);
        })

    /**
     * 上传视频
     * @param video 视频路径
     * @param mark 文件标示
     * @return progress 回调函数 用来监控上传进度
     * @return ret 返回的所有参数信息
     */
    publish.PublishVideoAsync({
        video: "videoFile",
        mark: 'fdf'
    }, progress => {
        console.log(`total--${progress.Total} progress--${progress.Uploaded / progress.Total}`);
    })
        .then(ret => {
            console.log('url:' + ret.url)
            console.log('id:' + ret.id)
            console.log('cover:' + ret.cover)
        })
        .catch(e => {
            console.error(e);
        })


    /**
     * 上传头像
     * @param ImagePublishParam(文件路径,文件标识)
     * @param usage 上传类型
     * @param duration 存储时间长度
     * @param resolutions 设置分辨率以及压缩比例
     * @return progress 回调函数 用来监控上传进度
     * @return ret 返回的所有参数信息
     */
    let param1 = new pu.ImagePublishParam(
        "imageFile",
        'mark'
    );
    param1.usage = pu.ImagePublishUsage.Headshot;
    param1.duration = -1;
    param1.resolutions = [
        {name: 'High', quality: 92, height: 200},
        {name: 'Low', quality: 80, scale: 0.3}
    ];
    publish.publishImageAsync(param1, progress => {
        console.log(progress.Uploaded / progress.Total);
    })
        .then(ret => {
            for (let img of ret) {
                console.log(`${img.name}: ${img.url}`);
            }
        })
        .catch(e => {
            console.error(e);
        })

    /**
     * 上传表情
     * @param ImagePublishParam(文件路径,文件标识)
     * @param usage 上传类型
     * @param duration 存储时间长度
     * @param resolutions 设置分辨率以及压缩比例
     * @return progress 回调函数 用来监控上传进度
     * @return ret 返回的所有参数信息
     * */
    let param2 = new pu.ImagePublishParam(
        "imageFile",
        'mark2'
    );
    param2.usage = pu.ImagePublishUsage.Meme;
    param2.duration = 0;
    publish.publishImageAsync(param2, progress => {
        ;
    }).then(ret => {
        for (let img of ret) {
            console.log(`${img.name}: ${img.url}`);
        }
    })

    /***
     * 上传插图
     * @param ImagePublishParam(文件路径,文件标识)
     * @param usage 上传类型
     * @param duration 存储时间长度
     * @param resolutions 设置分辨率以及压缩比例
     * @return progress 回调函数 用来监控上传进度
     * @return ret 返回的所有参数信息
     */
    let param3 = new pu.ImagePublishParam(
        "imageFile",
        'mark3'
    );
    param3.usage = pu.ImagePublishUsage.Figure;
    publish.publishImageAsync(param3, progress => {
        ;
    }).then(ret => {
        for (let img of ret) {
            console.log(`${img.name}: ${img.url}`);
        }
    })

    /**
     * 聊天上传原图(png, gif等)
     * @param ImagePublishParam(文件路径,文件标识)
     * @param usage 上传类型
     * @param duration 存储时间长度
     * @param resolutions 设置分辨率以及压缩比例
     * @return progress 回调函数 用来监控上传进度
     * @return ret 返回的所有参数信息
     */
    let param = new pu.ImagePublishParam(
        "imageFile",
        'mark3'
    );
    param.usage = pu.ImagePublishUsage.Meme;
    param.resolutions = [
        {name: 'Original', quality: 100},
        {name: 'High', quality: 90, scale: 0.8}
    ];
    publish.PublishImageAsync(param, progress => {
        ;
    }).then(ret => {
        for (let img of ret) console.log(`${img.name}: ${img.url}`);
    });
}