腾讯cos使用

1、腾讯cos免费试用6个月:https://console.cloud.tencent.com/cos

2、创建好bucket:

 3、Linux系统下coscmd工具安装,coscmd命令参考:https://cloud.tencent.com/document/product/436/10976

# yum install python3
# yum install gcc
# pip3 install coscmd -i    https://mirrors.aliyun.com/pypi/simple/

# 配置cos基本信息
[root@master ~]# cat /root/.cos.conf
[common]
secret_id = xxxxxxxx
secret_key = xxxxxxxx
bucket = jsonhc-1254359126
region = ap-shanghai

4、下载bucket数据到本地:

[root@master ~]# coscmd download logo.png ./
Download cos://jsonhc-1254359126/logo.png   =>   ./logo.pn
logo.png这张照片在bucket:jsonhc-1254359126下面
5、通过github action对cos数据进行下载
- name: download bucket from cos
  uses: zkqiang/tencent-cos-action@v0.1.0
  with:
    args: download logo.png ./
    secret_id: ${{ secrets.SECRET_ID }}
    secret_key: ${{ secrets.SECRET_KEY }}
    bucket: ${{ secrets.BUCKET }}
    region: ap-shanghai

执行结果如下:

 6、当bucket下面有多个文件时,download下载时:

 

[root@master ~]# coscmd download -rf / ./
Download cos://jsonhc-1254359126/devops.png   =>   ./devops.png
Download cos://jsonhc-1254359126/logo.png   =>   ./logo.png
2 files downloaded, 0 files skipped, 0 files failed
[root@master ~]# ls -lrth *.png
-rw-r--r-- 1 root root 120K Jul  3 12:06 devops.png
-rw-r--r-- 1 root root  34K Jul  3 12:06 logo.png

若本地存在同名文件,则会下载失败,需要使用 -f 参数覆盖本地文件



posted on 2024-07-03 23:41  wadeson  阅读(46)  评论(0编辑  收藏  举报