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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@aicloud360/sec-sdk-node

v0.1.2

Published

sec sdk with Node.js upload support

Readme

360AI云盘 Node.js SDK

360AI云盘 Node.js 客户端 SDK,提供文件上传等功能。

安装

npm install @aicloud360/sec-sdk-node

功能特性

  • 文件上传功能
    • 支持大文件分片上传
    • 断点续传
    • 自动重试机制
    • 进度监控
  • 支持 Node.js 环境
  • 支持 ES 模块和 CommonJS模块(未进行兼容性测试)

快速开始

文件上传示例

import { UploadNode } from '@aicloud360/sec-sdk-node';

// 创建上传配置
const config = {
  qid: process.env.ECS_QID || '0',
  token: process.env.ECS_TOKEN || '',
  access_token: process.env.ECS_ACCESS_TOKEN || '',
  env: process.env.ECS_ENV || 'prod',
  path: '/'
};

// 创建上传器实例
const uploader = new UploadNode(config, {
  success: (result) => {
    console.log('上传成功:', result);
  },
  progress: (fid, loaded, total, file) => {
    if (!loaded) {
      return;
    }
    console.log('id: ', fid, '上传进度:' + Math.floor((loaded / total) * 100) + '%', '文件:', file.name, '已上传:', formatSize(loaded), '总大小:', formatSize(total));
  },
  error: (file, error) => {
    console.error('上传失败:', file, error);
  },
  complete: () => {
    console.log('上传完成');
  },
  duplicateList: (list, resData) => {
    console.log('重复文件列表:', list, resData);
  }
});

// 监听事件
uploader.on('startupload', (folder, files) => {
  console.log('开始上传文件数量:', files.length);
});

uploader.on('filequeue', (isFolder, file) => {
  console.log('文件已加入队列:', file.name);
});

// 添加文件到上传队列
uploader.addWaitFile(['/path/to/file.txt']);

命令行测试

# 设置环境变量
export ECS_QID=your_qid
export ECS_TOKEN=your_token
export ECS_ACCESS_TOKEN=your_access_token

# 测试上传
npm run test:node-upload test-file.txt
或
export ECS_QID=your_qid ECS_TOKEN=your_token ECS_ACCESS_TOKEN=your_access_token ECS_ENV=test && node lib/upload/test-node-upload.js test-file.txt

支持以下命令行参数:

  • --debug - 启用调试模式
  • --verbose - 详细日志
  • --no-retry - 禁用重试
  • --no-boundary - 禁用自定义边界

API 文档

UploadNode 配置

| 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | qid | string | 是 | 用户QID | | token | string | 是 | 认证Token | | access_token | string | 是 | 访问Token | | env | string | 否 | 环境: prod/test/dev (默认: prod) | | path | string | 否 | 上传目标路径 (默认: /) |

事件列表

  • filequeue - 文件加入队列
  • startupload - 开始上传

开发

# 开发模式
npm run dev

# 构建生产版本
npm run build

# 发布
npm run release

依赖

  • Node.js 16+
  • form-data
  • node-fetch

常见问题

认证失败

确保配置正确的 qid, tokenaccess_token。Token 过期时可以通过设置 tokenRefreshCallback 自动刷新。

文件上传失败

检查文件路径是否正确,以及 Node.js 进程是否有足够的权限访问该文件。

许可证

Apache-2.0