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

@shencom/oss-browser

v1.0.0

Published

oss browser management

Downloads

2

Readme

@shencom/oss-browser

使用说明

介绍

oss-browser 通用 OSS sts 授权方式,限时在浏览器直接操作 oss;

此工具继承 @shencom/oss-core

基于 rollup/typescript 构建,ESModule;

安装

yarn add -D @shencom/oss-browser
# or
yarn add -D git+https://gitlab.shencom.cn/web/tools/oss-browser.git#master

初始化

  • 类型
interface Options {
  timeout?: number;
  bucket?: string;
  region?: string;
  accessKeySecret: string;
  accessKeyId: string;
  stsToken: string,
}
new OSS(ops: Options): OSS
  • 示例
import { OSS } from '@shencom/oss-browser';

const CLIENT = new OSS({
  timeout: 1000,
  bucket: 'string',
  region: 'string',
  accessKeySecret: 'string',
  accessKeyId: 'string',
  stsToken: 'string',
});

方法

list

  • 说明: 获取 oss 文件列表
  • 类型: OSSCore.list(ossPaths: string[] | string, returnType?: 'all', options?: AliOSS.ListV2ObjectsQuery): Promise<Pick<AliOSS.ListObjectResult, 'objects' | 'prefixes'>[]>
  • 参数:
    • ossPaths: oss 路径
    • returnType?: 返回类型,默认: all
    • options?: oss 配置,当 returnType=all 时生效
  • 示例:
    const list = await CLIENT.list(ossPaths, returnType, options);

delete

interface DeleteOption {
  ossPaths: Arrayable<string>;
  beforeEach?: (paths: Arrayable<string>) => void | boolean | Promise<boolean | void>;
}
  • 说明: 删除 oss 文件
  • 类型: OSSCore.delete(options: DeleteOption): Promise<void>
  • 参数:
    • options.ossPaths: oss 文件路径
    • options.beforeEach: 删除前
  • 示例:
    await CLIENT.delete(options);

put

interface PutOptions<O> {
  /** 对象名称存储在OSS上 */
  ossPath: string;
  /** String|Buffer|ReadStream|File(仅支持浏览器)|Blob(仅支持浏览器) 对象本地路径、内容缓冲区或 ReadStream 内容实例在 Node、Blob 和 html5 File 中使用 */
  file: any;
  options?: O;
  uploadOptions?: ((file: any, defaultOptions: Partial<O>) => Partial<O>) | Partial<O>;
}

type Upload = PutOptions<PutObjectOptions>;
  • 说明: 上传文件
  • 类型: OSSCore.put(config: Upload): Promise<AliOSS.PutObjectResult>
  • 参数: 参考上面类型
  • 示例:
    await CLIENT.put(config);

multipartUpload

interface PutOptions<O> {
  /** 对象名称存储在OSS上 */
  ossPath: string;
  /** String|Buffer|ReadStream|File(仅支持浏览器)|Blob(仅支持浏览器) 对象本地路径、内容缓冲区或 ReadStream 内容实例在 Node、Blob 和 html5 File 中使用 */
  file: any;
  options?: O;
  uploadOptions?: ((file: any, defaultOptions: Partial<O>) => Partial<O>) | Partial<O>;
}

type MultipartUpload = PutOptions<MultipartUploadOptions>;
  • 说明: 上传文件
  • 类型: OSSCore.multipartUpload(config: MultipartUpload): Promise<AliOSS.MultipartUploadResult>
  • 参数: 参考上面类型
  • 示例:
    await CLIENT.multipartUpload(config);