# @annexwu-packages/cos-upload-utils

> this is a utils which contains several cos upload functions

Latest version **0.0.10** (published 2023-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @annexwu-packages/cos-upload-utils
pnpm add @annexwu-packages/cos-upload-utils
yarn add @annexwu-packages/cos-upload-utils
bun add @annexwu-packages/cos-upload-utils
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.10 |
| Published | 2023-05-30 |
| First published | 2021-10-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 40.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | annexwu |
| Maintainers | annexwu |

## Links

- npm: https://www.npmjs.com/package/@annexwu-packages/cos-upload-utils
- npm.io page: https://npm.io/package/@annexwu-packages/cos-upload-utils

## Dependencies (4)

- [async](https://npm.io/package/async.md) ^3.2.0
- [cos-nodejs-sdk-v5](https://npm.io/package/cos-nodejs-sdk-v5.md) ^2.10.5
- [@annexwu-packages/simple-stream-utils](https://npm.io/package/@annexwu-packages/simple-stream-utils.md) ^0.0.3
- [@annexwu-packages/multiple-stream-utils](https://npm.io/package/@annexwu-packages/multiple-stream-utils.md) ^0.0.1

## Recent versions

- 0.0.10 (latest) — 2023-05-30
- 0.0.9 — 2022-08-14
- 0.0.8 — 2022-03-08
- 0.0.7 — 2021-11-23
- 0.0.6 — 2021-10-11
- 0.0.5 — 2021-10-08
- 0.0.4 — 2021-10-03
- 0.0.3 — 2021-10-02
- 0.0.2 — 2021-10-02
- 0.0.1 — 2021-10-02

## README

### @annexwu-packages/cos-upload-utils

## Usage

```js
const fs = require('fs');
const { CosUpload } = require('@annexwu-packages/cos-upload-utils');

async function test() {
  const cosUpload = new CosUpload({
    cos: {
      SecretId: 'xxx',
      SecretKey: 'xxx',
    },
    putObjectLimit: 5 * 1024 * 1024 * 1024,
    defaultChunkSize: 8 * 1024 * 1024,
  });

  const result = await cosUpload.runTask({
    object: {
      Bucket: 'xxx',
      Region: 'xxx',
      Key: 'xxx',
      ContentLength: 1024,
    },
    getRangeReadStream: (start, end) => {
      return fs.createReadStream('xxx', { start, end: end - 1 });
    },
    getReadStream: () => {
      return fs.createReadStream('xxx');
    },
  });
}

test();
```

## API

### CosUpload

Create a cos upload controller

```js
const fs = require('fs');
const { CosUpload } = require('@annexwu-packages/cos-upload-utils');

async function test() {
  const cosUpload = new CosUpload({
    cos: {
      SecretId: 'xxx',
      SecretKey: 'xxx',
    },
    putObjectLimit: 5 * 1024 * 1024 * 1024,
    defaultChunkSize: 8 * 1024 * 1024,
  });

  const result = await cosUpload.runTask({
    object: {
      Bucket: 'xxx',
      Region: 'xxx',
      Key: 'xxx',
      ContentLength: 1024,
    },
    getRangeReadStream: (start, end) => {
      return fs.createReadStream('xxx', { start, end: end - 1 });
    },
    getReadStream: () => {
      return fs.createReadStream('xxx');
    },
  });
}

test();
```

---
_Source: https://npm.io/package/@annexwu-packages/cos-upload-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
