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

@winman-f2e/nos-upload

v3.0.7

Published

## 配置说明 `host`及`endpoint`有三种配置方案: 1. 可以直接传递CDN的域名和host,比如`{host: 'nosdn.127.net', endpoint: 'https://easyreadfs.nosdn.127.net'}`,此时将会通过CDN中转上传,适合本地未连VPN或者外网情况,但是CDN域名可能存在不稳定的问题,建议搭配合适的retryCount配置使用 2. 可以传递NOS的内网源站域名,内网域名见内部Wiki,比如为`{host: 'nos.internal.n

Downloads

28

Readme

nos-upload

配置说明

hostendpoint有三种配置方案:

  1. 可以直接传递CDN的域名和host,比如{host: 'nosdn.127.net', endpoint: 'https://easyreadfs.nosdn.127.net'},此时将会通过CDN中转上传,适合本地未连VPN或者外网情况,但是CDN域名可能存在不稳定的问题,建议搭配合适的retryCount配置使用
  2. 可以传递NOS的内网源站域名,内网域名见内部Wiki,比如为{host: 'nos.internal.net', endpoint: 'http://nos.internal.net'},只支持http,适合本地连接了VPN或者内网服务器使用,此时需要搭配对应的objectOrigin参数,否则返回的资源url可能无法正确访问,url组装规则见下方使用示例中的注释
  3. 可以传递NOS的外网源站域名,源站域名见内部Wiki,比如为{host: 'nos.outside.net', endpoint: 'http://nos.outside.net'},此方式只支持http,适合不连VPN的本地开发场景或者外网使用场景,同样需要搭配对应的objectOrigin参数

安装和使用

$ npm install @winman-f2e/nos-upload

// nos配置请查看内部wiki文档
// 配置字段含义参照[`@nos-sdk/nos-node-sdk`](https://www.npmjs.com/package/@nos-sdk/nos-node-sdk)
const nosUpload = {
    accessKey: 'your-access-key',
    accessSecret: 'your-access-secret',
    host: 'nos.netease.com', 
    protocol: 'http',
    endpoint: 'http://nos.netease.com',
    defaultBucket: 'easyreadfs',
    objectOrigin: 'https://easyreadfs.nosdn.127.net' //可选,如果传递,将会作为返回的上传文件的url前缀,拼接方式为:objectOrigin + objectKey
} 
const getUploader = require('@winman-f2e/nos-upload')
const { uploadByContent, uploadByPath, uploadByStream } = getUploader(nosUpload)

uploadByPath(
    path.resolve(__dirname, './sentry-cli-Darwin-x86_64'), {
        prefix: '1.52.3/',
        name: 'sentry-cli-Darwin-x86_64',
        hash: false,
        retryCount: 5,
    }
).then(url => console.log('uploadFile:', url))
    .catch(err => console.log(err.message)) 

uploadByContent(
    'lalalalalaasdfsd', {
        prefix: 'fe_test/sub',
        name: 'file',
        ext: '.html',
        hash: false,
    }
).then(url => console.log('uploadText:', url))
    .catch(err => console.log(err.message))


const stream = require('stream');
const bufferData = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
const bufferStream = new stream.PassThrough();
bufferStream.end(bufferData);
//必须传入stream,以及它的length,不支持hash参数
uploadByStream(bufferStream, bufferData.length, {
  prefix: 'snailreader_node',
  name: 'screenshot' + Date.now(),
  ext: '.' + type,
}).then(url => console.log('uploadText:', url))
    .catch(err => console.log(err))

changelog

v3.1:

  • 更换上传nos-sdk为@nos-sdk/nos-node-sdk

v3.0:

  • 更换上传nos-sdk为@xgheaven/nos-node-sdk来解决cdn节点报错没有触发重试机制的问题
  • 上传的nos config字段格式修改为@xgheaven/nos-node-sdk的格式

v2.2

增加stream上传接口,使用方式见/example/upload.js:

v2

修改上传接口,使用方式见/example/upload.js,参数信息见/index.js注释