16.1.5 • Published 9 months ago

@yuntools/ali-oss v16.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

ali-oss

阿里云 OSS 命令行工具 ossutil 封装,支持 ESM,CJS 导入,提供 TypeScript 类型定义

安装

npm i @yuntools/ali-oss

安装命令行工具

Linux

下载页面

sudo wget https://gosspublic.alicdn.com/ossutil/1.7.11/ossutil64 -O /usr/bin/ossutil
sudo chmod a+x /usr/bin/ossutil

使用

Typescript 工程

// foo.ts
import assert from 'node:assert'
import { OssClient, Config } from '@yuntools/ali-oss'

const ossConfig: Config = {
  endpoint: 'https://oss-cn-hangzhou.aliyuncs.com',
  accessKeyId: 'foo',
  accessKeySecret: 'bar',
}
const client = new OssClient(ossConfig)

const bucket = 'my-bucket'

// 创建目录
const target = 'foo/barz'
const opts: UploadOptions = {
  bucket,
  target,
}
const mkRet = await client.mkdir(opts)
assert(! mkRet.exitCode, `mkdir ${opts.target} failed, ${mkRet.stderr}`)


// 上传本地文件
const src = 'tsconfig.json'
const target = `foo/tsconfig.json`
const opts: UploadOptions = {
  bucket,
  src,
  target,
}
const ret = await service.upload(opts)
assert(! ret.exitCode, `upload ${src} ${dst} failed, ${ret.stderr}`)
assert(ret.data)

CLI 命令行

安装执行环境

cd example
npm i

执行脚本

cd example

# zx 执行器
./zx-import.mjs
./zx-require.mjs

# ts-node 执行器
./ts-node-import.ts

OSS 操作实例方法

  • cp() 在远程拷贝
  • createSymlink() 创建软连接
  • mkdir() 创建目录
  • mv() 在远程移动对象
  • pathExists() 检测远程文件是否存在
  • rm() 删除远程对象
  • rmrf() 删除远程对象及其下级所有对象
  • stat() 获取远程对象属性
  • syncRemote() (强制)同步本地目录到远程
  • syncLocal() (强制)同步远程到本地目录
  • upload() 上传本地文件到远程

License

MIT

16.1.5

9 months ago

16.1.4

1 year ago

16.1.3

1 year ago

16.1.2

2 years ago

16.1.1

2 years ago

16.1.0

2 years ago

16.0.0

2 years ago

15.3.0

2 years ago

15.2.1

2 years ago

15.2.0

2 years ago

15.1.1

2 years ago

15.1.0

2 years ago

15.0.1

2 years ago

15.0.0

2 years ago

14.0.1

2 years ago

14.0.0

2 years ago

13.1.0

2 years ago

13.0.1

2 years ago

13.0.0

2 years ago

12.3.0

2 years ago

12.2.0

2 years ago

12.1.0

2 years ago

12.0.1

2 years ago

12.0.0

2 years ago

11.3.0

2 years ago

11.2.0

2 years ago

11.1.0

2 years ago

11.0.1

2 years ago

11.0.0

2 years ago

10.0.0

2 years ago

9.0.0

2 years ago

8.3.1

2 years ago

8.3.0

2 years ago

8.2.0

2 years ago

8.1.0

2 years ago

8.0.0

2 years ago

7.0.1

2 years ago

7.0.0

2 years ago

6.4.0

2 years ago

6.3.2

2 years ago

6.3.1

2 years ago

6.3.0

2 years ago

6.2.0

2 years ago

6.1.0

2 years ago

6.0.0

2 years ago

5.3.0

2 years ago

5.2.0

2 years ago

5.1.1

2 years ago

5.1.0

2 years ago

5.0.0

2 years ago

4.0.0

2 years ago

3.3.0

2 years ago

3.2.0

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago