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

@panhezeng/ucloud-ufile

v1.0.13

Published

ucloud upload file jssdk

Downloads

21

Readme

ucloud-ufile

示例

点击预览

示例代码目录 /example

示例使用的 mock 接口模拟了 ucloud 接口的 Response,实际应用中这三个 bucketName = '', bucketUrl = '', tokenServerUrl = ''参数,需要用户自己配置

示例使用的 apiary mock 服务每次 Request 获得的 Response 都是不变的。免费服务可能会出现无响应等错误

说明

基于 ucloud 官方 jssdk,在保证官方 api 命名,参数,返回结果一致的前提下,进行严重 bug 修复和代码优化精简等,并且提供 npm 使用方式。主要动了秒传和分片上传相关代码,其他 api 代码几乎和官方一样,有 bug 提 issue,或者自己 fork 修改。

bug 修复: 1.修复 signatureServer 逻辑会立即触发 error 回调问题

优化: 1.换成 class 写法 2.去掉了本地计算 token 的代码,从安全性来说,一般都是通过服务器获得 token,从开发角度来说,也没必要把两个功能耦合到一起,一是代码冗余,二是容易产生 bug,比如上面修复的 bug。 3.调整了每次都执行 getContentMd5 方法,后执行获得 token 方法的逻辑,通过阅读官方源码发现只需要 Object.prototype.toString.call(file) === '[object File]'&& md5Required !== false 条件下执行 4.增加 check 方法,检查 API 第一个必传参数 5.增加了 hitSliceUpload 方法,先秒传,如果秒传失败再分片上传,用文件相关信息作为文件夹名称,保证唯一性,否则同名文件会被覆盖

本模块已正式使用于多个生产项目

用法

npm i @panhezeng/ucloud-ufile -S

import UCloudUFile from "@panhezeng/ucloud-ufile";

or

<script src="https://cdn.jsdelivr.net/npm/@panhezeng/ucloud-ufile@latest/dist/ucloud-ufile.min.js"></script>

具体读本模块示例代码和 ucloud 官方官方文档(https://github.com/ufilesdk-dev/ufile-jssdk)

编译

# install dependencies
npm install

# 运行插件使用示例
npm run dev:example

# 编译插件
npm run build

# 发版
npm set @panhezeng:registry https://registry.npmjs.org/ && npm version patch && npm publish --access public && npm set @panhezeng:registry https://registry.npm.taobao.org/