Upload SDK for WeChat Mini Program

Last updated: 2020-01-20 15:39:41
This document is currently invalid. Please refer to the documentation page of the product.

    VOD provides a video upload SDK for WeChat Mini Program. For more information on the upload process, please see Guide for Upload from Client.

    • If you need the SDK source code, please click here.
    • If you need the Demo source code, please click here.

    Video Upload Steps

    1. Import the SDK

    const VodUploader = require('../../lib/vod-wx-sdk-v2.js');

    2. Define the function to get an upload signature

    getSignature: function(callback) {
            url: 'https://xzb.qcloud.com/get_vod_sign',
            method: 'POST',
            data: {
                Action: 'GetVodSignatureV2'
            dataType: 'json',
            success: function(res) {
                if (res.data && res.data.data.signature) {
                } else {
                    return 'Failed to get the signature';

    3. Upload a video
    Video upload is implemented by calling VodUploader.start, and video selection is implemented by the wx.chooseVideo method in the WeChat Mini Program API. Below is an example:

        mediaFile: videoFile, // Pass in the `file` parameter called back by `chooseVideo`, which is required
        getSignature: getSignature, // The function to get the signature, which is required
        mediaName: fileName, // Video name, which is optional. You are strongly recommended to enter this parameter, and if it is left empty, "From WeChat Mini Program" will be used by default
        coverFile: coverFile, // Video cover, which is optional
        success: function(result) {
        error: function(result) {
                title: 'Upload failed',
                content: JSON.stringify(result),
                showCancel: false
        progress: function(result) {
        finish: function(result) {
                title: 'Upload succeeded',
                content: 'fileId:' + result.fileId + '\nvideoName:' + result.videoName,
                showCancel: false


    1. As the WeChat Mini Program does not have an API to get the actual filename, you need to enter the video name before uploading the video; otherwise, the SDK will set the video name to "From WeChat Mini Program".
    2. Resumable upload and multipart upload are not supported.
    3. In the WeChat Mini Program domain name information, simply add vod2.qcloud.com to a valid domain name for request and uploadFile.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback