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

aplus-oss

v1.0.5

Published

aplus use ali-oss

Downloads

225

Readme

APLUS OSS

Rebuild ali-oss javascript sdk that provie private sts server methods

Quick start

//add -w in you root folder
pnpm install aplus-oss -S -w

Usage example

//register client instance
import { client } from 'aplus-oss'

//some code in you project
import { you_STS_server } from '@/api/sts'

//init oss access token
const ossIntsance = client.initOssClient({
  you_STS_server,
  onFailure: err => {
    console.warn('get oss accessSerct fail', err)
  }
})

//after init
//you can use ossIntsance do something

ossIntsance.put(..)
ossIntsance.getSignatureUrl(..)
ossIntsance.downloadFile(..)
ossIntsance.deleteFile(..)
ossIntsance.pauseUpload(...)


// upload image or vedio with oss
// your can use put method to upload
const result = await client.put({
  fileName: file.name,
  dirName: 'Vedio',
  data: file,
  progressCallBack: (p: number) => {
    percentVeido.value = p
  },
  //the number of parts to be uploaded in parallel
  parallel: 6,
  //the suggested size for each part, defalut 1024 * 1024(1MB), minimum 100 * 1024(100KB)
  partSize: 1024 * 1024
})

if (result.status === 200) {
  const { status, previewUrl, saveUrl } = result
  console.log('status---', status)
  console.log('previewUrl---', previewUrl)
  console.log('saveUrl---', saveUrl)
} else {
  //failure
  console.log(result.message)
}

//you can use download method to download
let res = client.downloadFile(fileName)
console.log(res.message)
console.log(res.status)
//you can  get signature url to perview with  getSignatureUrl method
let signatureUrl = client.getSignatureUrl(pathName)
//get signature url
//after expires seconds, the url will become invalid, default is 3600s
console.log(signatureUrl)

//delete file
let res = await client.deleteFile(pathName)
console.log(res)

//pauseUpload
let res = = await client.pauseUpload()
console.log(res)

Methods

initOssClient

type: initOssClient(options: ResquestOssOptions): Promise<Oss>;

tips: register client instance with you sts server

ResquestOssOptions

| props | type | default | directions | | --- | --- | --- | --- | | getOssAccess | () => Promise<accessCreate> | - | init oss access token | | onFailure | (err: any) => void | - | get oss accessSerct fail |

put

type: put({ fileName, dirName, data, progressCallBack, parallel, partSize }: uploadParams): Promise<actionResponse>;

tips: you can put image vedio with put core method

options

| Props | Type | default | explanation | | --- | --- | --- | --- | | fileName | string | - | file Name | | dirName | string | - | upload folder name | | data | File | - | upload data | | progressCallBack | (p:number) => void | - | upload progress | | parallel | number | 6 | the number of parts to be uploaded in parallel | | partSize | number | 1024*1024(1M) | the suggested size for each part, defalut 1024 _ 1024(1MB), minimum 100 _ 1024(100KB) |

actionResponse | Props | Type | default | explanation | | --- | --- | --- | --- | | status | number | - | status code(success 200 ,other will be fail) | | previewUrl | string | - | preview file url,you can preview image or vedio after uploaded| | saveUrl | string | - |your backend server wille be save this path| | message | string | - |success message or fail message|

downloadFile

type: downloadFile(savePathName: Array<string> | string): Promise<actionResponse>;

tips: dowload file with downloadFile method (support multiple download files)

options

| Props | Type | default | explanation | | --- | --- | --- | --- | | savePathName | Array<string> \| string | - | if mutipart download will be arrary,single file download wille be string |

actionResponse | Props | Type | default | explanation | | --- | --- | --- | --- | | status | number | - | status code(success 200 ,other will be fail) | | previewUrl | string | - | preview file url,you can preview image or vedio after uploaded| | saveUrl | string | - |your backend server wille be save this path| | message | string | - |success message or fail message|

getSignatureUrl

type: getSignatureUrl(name: string, expires?: number): Promise<string>;

tips: get signature url to perview

options

| Props | Type | default | explanation | | ------- | -------- | ------- | -------------- | | name | string | - | file path name | | expires | number | 3600(s) | expires time |

deleteFile

type: deleteFile(savePathName: string): Promise<{status: any;message: string;} | undefined>;

tips: delete oss file options

| Props | Type | default | explanation | | ------------ | -------- | ------- | -------------- | | savePathName | string | - | file path name |

pauseUpload

type: pauseUpload(): Promise<{status: number;message: globMessage;}>

tips: pause upload