New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@annexwu-packages/cos-upload-utils

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@annexwu-packages/cos-upload-utils

this is a utils which contains several cos upload functions

latest
npmnpm
Version
0.0.10
Version published
Maintainers
1
Created
Source

@annexwu-packages/cos-upload-utils

Usage

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

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();

FAQs

Package last updated on 30 May 2023

Related posts