aliyun ossutil notes

  • 下载 ossutil
  • 使用 ossutil 创建 bucket
  • 同步文件夹功能
  • 查看 ossutil 配置
  • 最佳实践
  • brew & tree 安装

All OSS utils

下载 ossutil

https://help.aliyun.com/document_detail/44075.html

ossutil

设置用户信息并测试创建 bucket

$ mv ossutilmac64 ossutil
$ chmod +x ossutil
$ ./ossutil config 
输入 RAM key & secret
$ ./ossutil mb oss://zhoukekestar20180405test
0.288786(s) elapsed

到 oss 控制台查看,已创建成功

同步文件夹

  • 创建临时文件夹
  • 使用 ./ossutil cp -r osstemp oss://zhoukekestar20180405test 命令同步到 oss
➜  Downloads mkdir osstemp
➜  Downloads touch osstemp/a.txt
➜  Downloads ls osstemp
a.txt
➜  Downloads mkdir osstemp/bdir
➜  Downloads touch osstemp/bdir/b.txt
➜  Downloads tree osstemp
osstemp
├── a.txt
└── bdir
    └── b.txt

1 directory, 2 files
➜  Downloads ./ossutil cp -r osstemp oss://zhoukekestar20180405test
Succeed: Total num: 3, size: 0. OK num: 3(upload 2 files, 1 directories).
0.260253(s) elapsed

查看 oss 配置

➜  ~ cat ~/.ossutilconfig
[Credentials]
language=EN
endpoint=oss-cn-shanghai.aliyuncs.com
accessKeyID=xxx
accessKeySecret=xxx

最佳实践

  • -r 上传目录
  • -u 只做更新
#!/bin/bash

ossutil cp -u -r ./images oss://xxx/images
ossutil cp -u ./index.html oss://xxx
ossutil cp -u ./404.html oss://xxx

Brew & tree 命令安装

➜  Downloads tree
zsh: command not found: tree
➜  Downloads brew install tree
zsh: command not found: brew
➜  Downloads /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
...
➜  Downloads brew install tree
==> Downloading https://homebrew.bintray.com/bottles/tree-1.7.0.sierra.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring tree-1.7.0.sierra.bottle.1.tar.gz
🍺  /usr/local/Cellar/tree/1.7.0: 7 files, 113.3KB
➜  Downloads

References