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

ulearning-obs

v0.0.64

Published

obs

Readme

ulearning-obs

介绍

优学院文件服务obs,上传,下载等

软件架构

javascript 依赖华为obs以及七牛云sdk

安装教程

  1. npm i ulearning-obs

使用说明

支持全局引入 amd cmd es6 dist目录输出两个版本的工具类 obs-huawei.js obs-qiniu.js分别对应华为云和七牛云

const Obs = require('ulearning-obs')
//or
import Obs from 'ulearning-obs'
//or
<script src="node_modules/ulearning-obs/dist/obs-huawei.js"></script>

使用

  • new Obs({fileTypes?: Array, mode?: string, maxSize?: number, exts?: string, multiple?: Boolean,uptokenHost,m3u8?: Boolean})
    • fileTypes Array 文件类型 document image video audio zip flash srt 优学院对应文件类型格式,不传该字段默认支持全部文件类型
    • maxSize 文件最大限制 单位mb 默认1024
    • exts 扩展名doc,doc,xls等 多个用','隔开 覆盖type对应的扩展名
    • multiple 文件选择是否支持多选 true or false
    • errorCode 50001 文件类型不支持 50002 文件大小不符合 50070 七牛云token获取失败 50071七牛上传时失败 50080 华为token获取失败 50081华为上传时失败 50082 文件编码无法解析
    • uptokenHost 获取上传token的接口host 决定传到哪个服务器 cn app net ex:https://courseapi.tongshike.cn
    • m3u8 视频文件是否需要转码成m3u8格式(默认转码成MP4格式,如果此参数为true 会额外转码一份m3u8格式文件,回调的file文件会增加m3u8Key属性,值为转码后的m3u8文件路径)
    • authorization 上传接口权限校验(优学院账号)
    • obsSign 非优学院账号使用签名校验权限
    • obsHost 上传后文件的访问域名 七牛云上传的时候需要传此参数 华为云上传不需要 ex:https://leicloud.ulearning.cn
let obs = new Obs({
  maxSize: 10,
  fileTypes: [],
  multiple: true
})
  • obs.initUpBtn(dom: dom) 给目标dom绑定文件选择上传
obs.initUpBtn(document.getElementById('uploaderBtn'))
  • 监听函数 obs实例可绑定用于文件上传的监听事件
    • onBeforeUpload
    • onError
    • onSuccess
    • onProgress
obs.onBeforeUpload = function (file) {
  console.log('onBeforeUpload----',file)
    file.onProgress = function (percent) {
      console.log('progress----file-----' + percent)
    }
    file.onSuccess = function () {
      console.log('success----file-----')
    }
    file.onError = function (err) {
      console.log('error----file-----' + err)
    }
}
obs.onError = function (file,err) {
  console.log('error',file,err)
}
obs.onSuccess = function (file) {
  console.log('success----',file)
}
obs.onProgress = function (file,percent) {
  console.log('progress----',file, percent)
}
  • obs.startUpload(file:File or Blob) 上传文件函数 支持File,Blob file(or blob)对象需要指定ext参数用于确定文件类型
file.ext = '.png'
obs.startUpload(file) or
obs.startUpload(blob)
  • obs.cancelUpload(file:Object) 取消上传
obs.cancelUpload(uploader.files[0])
  • obs.download(path,name) 下载文件,path:传入文件路径的全路径 name:下载后的文件名称 ex:abc.png 不传默认用key作为名字
obs.download('https://tongshike.obs.cn-north-4.myhuaweicloud.com/resources/web/16371358301228191.png')

0.0.17

增加音频默认转成流程(暂未开启)

0.0.25

转码源文件path路径处理(去除域名)

0.0.26

增加说转码失败code 50082

0.0.28

默认文件改为obs-qiniu.js download参数拼接优化

0.0.30

去除eval方法

0.0.31

华为云上传文件访问域名从后台直接获取domain

0.0.32

上传文件音视频增加duration参数

0.0.33

startUpload支持duration

0.0.34

音视频duration,从华为mpc获取

0.0.35

七牛file.key赋值错误修复

0.0.36

处理host多余斜杠 mp4转码失败正常走成功回调 提供新的qiniuUploadByToken方法,用于业务端自行获取token再进行上传

0.0.37

m3u8key以及转code=2修改

0.0.38

重新实现了download方法

0.0.39

without-polyfill

0.0.40

优化时长获取

0.0.41

时长获取回调bug修复

0.0.42

下载修改

0.0.43

下载方法重构

0.0.43

中文名下载bug

0.0.45

文件下载mp4格式

0.0.46

新增obs-nxu.js,宁夏大学本地部署定制

0.0.47

修改qiniu版本,自定义file key

0.0.48

增加obsSign参数,非优学院账号使用此签名参数获取上传下载配置

0.0.49

mp3增加转码(后台根据编码格式判断是否需要转码)

0.0.50

增加getDownloadUrl(path,name,callback)方法,和download类似,获取url是异步的需多传入一个回调函数

0.0.51

新增obs-cdp.js,宁夏大学本地部署定制

0.0.52

新增文档类型pps

0.0.53

新增obs-zuel.js,中南财大本地部署定制

0.0.54

新增7z xmind psd dwg格式文件

0.0.55

新增分段上传功能

0.0.56

修复分段上传的文件未返回obsHost问题

0.0.57

增加isMediaLengthNotNeeded参数 是否不获取视频时长

0.0.58

isMediaLengthNotNeeded bugfix

0.0.59

如果有预览地址,上传文件后直接从接口获取预览地址

0.0.60

isVideoTranscodeNotNeeded 新增参数 是否视频不需要转码

0.0.61

下载接口新增token

0.0.62

更新README.md

0.0.63

下载接口新增token build