标签:lan 腾讯 conf file reg ide print 用户 xxxxx
# -*- coding: UTF-8 -*-
‘‘‘=================================================
@Project -> File :MyDjango -> cos_upload_demo
@IDE :PyCharm
@Author :ruochen
@Date :2020/7/17 11:52
@Desc :
@Install: pip install -U cos-python-sdk-v5
==================================================‘‘‘
from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
import uuid
secret_id = ‘自己id‘ # 替换为用户的 secretId
secret_key = ‘自己key‘ # 替换为用户的 secretKey
region = ‘ap-nanjing‘ # 替换为用户的 Region
config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key)
client = CosS3Client(config)
filename = str(uuid.uuid4())
response = client.upload_file(
Bucket=‘xxxxxxx‘,
LocalFilePath=‘xxxxx.png‘, # 本地文件的路径
Key = filename, # 上传到桶之后的文件名
)
print(response[‘ETag‘])
标签:lan 腾讯 conf file reg ide print 用户 xxxxx
原文地址:https://www.cnblogs.com/wuxiaoshi/p/14246015.html