0.0.1 • Published 5 months ago

lee-cos v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

COS Upload Tools

一、 安装

# npm
npm install @lee/cos-upload -D

# pnpm
pnpm install @lee/cos-upload -D

# yarn
yarn add @lee/cos-upload -D

二、配置

1. 默认配置文件

根目录创建cos.config.js文件,配置如下:

import { resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))

export default {
  cosConfig: {
    SecretId: '***',
    SecretKey: '***',
    Region: '***',
    BucketName: '***'
  },
  task: [
    {
      source: resolve(__dirname, '****'),
      target: '/'
    }
    ...
  ]
}

target为上传到 cos 的路径,默认为根目录,需以/开始或结束,一个/为上传至当前 bucket 的根目录。

2. 自定义配置文件

自定义创建配置文件,例如:example.js,在文件中新增以上配置,并通过--config参数指定配置文件路径。

npx cos --config example.js

三、参数支持

参数简称说明
--config--c指定配置文件路径,默认为cos.config.js
--region--rcos 存储桶配置的区域信息
--id--icos 秘钥 id 值
--key--kcos 秘钥 key 值
--bucket--bcos 存储桶名称

可通过以上参数配置 cos 相关信息,例如:

npx cos --config example.js --region *** --id *** --key *** --bucket ***

#or

npx cos --c example.js --r *** --i *** --k *** --b ***
0.0.1

5 months ago