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

@mingto/minio-obs-server

v1.0.21

Published

minio文件上传

Downloads

800

Readme

@mingto/minio-obs-server

文件上传至 MinIO 对象存储服务工具库,支持单文件上传。

特性

  • 🚀 简单易用:单文件上传,快速集成
  • 📊 进度监控:实时上传进度回调
  • 取消上传:支持随时取消上传操作
  • 🔧 灵活配置:支持自定义配置参数
  • 📱 浏览器端支持:专为浏览器环境优化

安装

pnpm add @mingto/minio-obs-server

快速开始

import minioObsServer from '@mingto/minio-obs-server'

// 配置全局参数
minioObsServer.config({
  getToken: () => '用户的token'
})

// 创建要上传的文件对象
const sourceFile = new File(['hello world'], 'hello.txt', { type: 'text/plain' })

// 创建上传实例
const uploadContext = minioObsServer.create({
  sourceFile,
  onProgress: (event) => {
    console.log(`上传进度: ${event.percent}%`)
  },
  onSuccess: (event) => {
    console.log('上传成功:', event.fileInfo)
  },
  onError: (error) => {
    console.error('上传失败:', error.code, error.message)
  }
})

// 取消上传
// uploadContext.abort()

API

全局配置

minioObsServer.config(options)

配置全局参数,支持以下参数:

| 参数 | 类型 | 必填 | 默认值 | 说明 | |------|------|------|--------|------| | getToken | () => string | 是 | 无 | 用于获取上传所需的 token,该 token 用于身份验证 |

创建上传实例

minioObsServer.create(options)

创建上传实例,支持以下参数:

| 参数 | 类型 | 必填 | 默认值 | 说明 | |------|------|------|--------|------| | sourceFile | File | 是 | 无 | 要上传的文件对象 | | sceneId | '0' \| '1' | 否 | '1' | 上传桶的类型,'0' 为私有桶,'1' 为公共桶(默认) | | onStart | () => void | 否 | () => {} | 上传开始时的回调 | | onProgress | (event) => void | 否 | () => {} | 上传进度回调,event.percent 表示百分比 | | onSuccess | (event) => void | 否 | () => {} | 上传成功回调,event 包含 sourceFilefileInfo | | onError | (error) => void | 否 | () => {} | 上传失败回调 | | onAbort | () => void | 否 | () => {} | 取消上传时的回调 | | onFinally | () => void | 否 | () => {} | 上传结束回调(无论成功或失败) |

取消上传

uploadContext.abort()

取消当前上传。

uploadContext.abort()

错误处理

上传过程中出现错误时,会抛出对应的 ObsError 对象,可通过 error.code 获取错误码。

| 错误码 | 描述 | |--------|------| | 10001 | 请求失败,请检查网络 | | 10007 | 文件上传取消失败,请检查网络 |

注意事项

  • 本工具库依赖 axios,请确保项目中已安装 axios,版本要求为 ^1.7.9
  • 请确保返回的 token 是有效的,否则可能导致上传失败

许可证

MIT