[toc]
腾讯云cos上传
官方文档:腾讯云-COSCMD 工具
一、主要步骤:
使用 pip install coscmd
需要:①使用python3安装pip、②使用pip install coscmd、③使用coscmd上传文件
其他:brew
1
| /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
1、python3
找不到python3的bin地址可使用如下命令:
2、pip
在 Mac 上为 Python 3 使用 PIP 安装脚本
1 2 3
| curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
|
以上脚本来源于:如何在 Mac 上安装 PIP

安装失败,原因未设置到环境变量中,通过如下命令即可设置新增环境变量
1 2 3 4 5 6 7 8 9 10 11
| which pip
# 非M1芯片的MacOS使用如下: echo 'export PATH=~/Library/Python/3.8/bin:$PATH' >>~/.zshrc source ~/.zshrc
# 非M1芯片的MacOS使用如下: echo 'export PATH=~/Library/Python/3.8/bin:$PATH' >>~/.bash_profile source ~/.bash_profile
which pip
|
错误修改参考于文章:Pip安装警告:Consider adding this directory to PATH..
3、COSCMD 工具安装
官方文档:腾讯云-COSCMD 工具
我们使用通过 pip 安装方式安装 COSCMD。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| pip install coscmd
coscmd -v which coscmd
# 非M1芯片的MacOS使用如下: echo 'export PATH=~/Library/Python/3.8/bin:$PATH' >>~/.zshrc source ~/.zshrc
# 非M1芯片的MacOS使用如下: echo 'export PATH=~/Library/Python/3.8/bin:$PATH' >>~/.bash_profile source ~/.bash_profile
which pip
|

4、COSCMD 工具使用
COSCMD 工具在运行前会首先从配置文件中读取运行时所需的必要信息,COSCMD 会默认从 ~/.cos.conf
中读取配置项。
所以,在~目录下,新建.cos.conf
文件,并配置上类似如下的信息:
1 2 3 4 5 6 7 8 9 10 11 12
| [common] secret_id = AKIDA6wUmImTMzvXZNbGLCgtusZ2E8mG**** secret_key = TghWBCyf5LIyTcXCoBdw1oRpytWk**** bucket = configure-bucket-1250000000 region = ap-chengdu max_thread = 5 part_size = 1 retry = 5 timeout = 60 schema = https verify = md5 anonymous = False
|
1 2 3 4 5 6 7 8
| # 非M1芯片的MacOS使用如下: echo 'export PATH=/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/itms/bin:$PATH' >>~/.zshrc source ~/.zshrc
# 非M1芯片的MacOS使用如下: echo 'export PATH=/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/itms/bin:$PATH' >>~/.bash_profile source ~/.bash_profile
|
之后即可正常安装腾讯云-对象存储-Python SDK
1
| pip install -U cos-python-sdk-v5
|

End
至此,利用腾讯云Cos上传文件的操作介绍结束。