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 🙏

© 2024 – Pkg Stats / Ryan Hefner

aliyun-upload-vod

v1.0.6

Published

阿里云点播视频上传SDK npm版本

Downloads

41

Readme

aliyun-upload-vod

npm version

简介

阿里云视频点播上传SDK是阿里视频云端到云到端服务的重要一环,为您提供上传媒体文件到点播存储的开发工具包。集成点播上传SDK,就可以快捷上传包括视频、音频、图片、字幕等在内的各种媒体文件。同时提供服务端、Web端、移动端等多种版本SDK,全面适配各个主流平台和运行环境。 官方文档

开发

安装

npm install aliyun-upload-vod

使用

import as module

import AliyunUpload from "aliyun-upload-vod";

global

    import AliyunUpload from 'aliyun-upload-vod';

    var uploader = new AliyunUpload.Vod({
      //阿里账号ID,必须有值
      userId: '1303984639806000',
      //上传到视频点播的地域,默认值为'cn-shanghai',//eu-central-1,ap-southeast-1
      region: 'cn-shanghai',
      //分片大小默认1 MB,不能小于100 KB
      partSize: 1048576,
      //并行上传分片个数,默认5
      parallel: 5,
      //网络原因失败时,重新上传次数,默认为3
      retryCount: 3,
      //网络原因失败时,重新上传间隔时间,默认为2秒
      retryDuration: 2,
      //添加文件成功
      addFileSuccess: () => {
        if (uploader !== null) {
          uploader.startUpload();
        }
      },
      //开始上传
      onUploadstarted: (uploadInfo) => {
        // 如果是 UploadAuth 上传方式, 需要调用 uploader.setUploadAuthAndAddress 方法
        // 如果是 UploadAuth 上传方式, 需要根据 uploadInfo.videoId是否有值,调用点播的不同接口获取uploadauth和uploadAddress
        // 如果 uploadInfo.videoId 有值,调用刷新视频上传凭证接口,否则调用创建视频上传凭证接口
        // 注意: 这里是测试 demo 所以直接调用了获取 UploadAuth 的测试接口, 用户在使用时需要判断 uploadInfo.videoId 存在与否从而调用 openApi
        // 如果 uploadInfo.videoId 存在, 调用 刷新视频上传凭证接口(https://help.aliyun.com/document_detail/55408.html)
        // 如果 uploadInfo.videoId 不存在,调用 获取视频上传地址和凭证接口(https://help.aliyun.com/document_detail/55407.html)
        if (!uploadInfo.videoId) {
          let createUrl = 'https://demo-vod.cn-shanghai.aliyuncs.com/voddemo/CreateUploadVideo?Title=testvod1&FileName=aa.mp4&BusinessType=vodai&TerminalType=pc&DeviceModel=iPhone9,2&UUID=59ECA-4193-4695-94DD-7E1247288&AppVersion=1.0.0&VideoId=5bfcc7864fc14b96972842172207c9e6'
          axios.get(createUrl).then(({data}) => {
            let uploadAuth = data.UploadAuth
            let uploadAddress = data.UploadAddress
            let videoId = data.VideoId
            uploader.setUploadAuthAndAddress(uploadInfo, uploadAuth, uploadAddress,videoId)
          })
          self.statusText = '文件开始上传...'
          console.log("onUploadStarted:" + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object)
        } else {
          // 如果videoId有值,根据videoId刷新上传凭证
          // https://help.aliyun.com/document_detail/55408.html?spm=a2c4g.11186623.6.630.BoYYcY
          let refreshUrl = 'https://demo-vod.cn-shanghai.aliyuncs.com/voddemo/RefreshUploadVideo?BusinessType=vodai&TerminalType=pc&DeviceModel=iPhone9,2&UUID=59ECA-4193-4695-94DD-7E1247288&AppVersion=1.0.0&Title=haha1&FileName=xxx.mp4&VideoId=' + uploadInfo.videoId
          axios.get(refreshUrl).then(({data}) => {
            let uploadAuth = data.UploadAuth
            let uploadAddress = data.UploadAddress
            let videoId = data.VideoId
            uploader.setUploadAuthAndAddress(uploadInfo, uploadAuth, uploadAddress,videoId)
          })
        }
      },
      //文件上传成功
      onUploadSucceed: () => {
        this.$message.success('文件上传成功');
      },
      //文件上传失败
      onUploadFailed: () => {
        this.$message.error('文件上传失败');
      },
      //文件上传进度,单位:字节
      onUploadProgress: (uploadInfo, totalSize, loadedPercent) => {
        this.loadedPercent = Math.ceil(loadedPercent * 100);
        console.log(this.loadedPercent);
      },
      //上传凭证或STS token超时
      onUploadTokenExpired: () => {
        this.$message.error('文件上传token超时');
      },
      //全部文件上传结束
      onUploadEnd: () => {
        console.log("onUploadEnd: uploaded all the files")
      }
    });
    var userData = '{"Vod":{}}';
    uploader.addFile(file.raw, null, null, null, userData);
  }

文档

Documents

License

The ISC License(https://opensource.org/licenses/ISC)

请自由地享受和参与开源