0.0.1 • Published 10 months ago
lee-cos v0.0.1
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 | --r | cos 存储桶配置的区域信息 |
| --id | --i | cos 秘钥 id 值 |
| --key | --k | cos 秘钥 key 值 |
| --bucket | --b | cos 存储桶名称 |
可通过以上参数配置 cos 相关信息,例如:
npx cos --config example.js --region *** --id *** --key *** --bucket ***
#or
npx cos --c example.js --r *** --i *** --k *** --b ***0.0.1
10 months ago