One - One Code All

Blog Content

python读取阿里云oss文件

Python   2020-03-28 16:26:19

可以参考阿里云官方手册:

# -*- coding: utf-8 -*-
import oss2

# 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
auth = oss2.Auth('', '')
# Endpoint以杭州为例,其它Region请按实际情况填写。
bucket = oss2.Bucket(auth, 'http://oss-cn-hangzhou.aliyuncs.com', '')

# 下载OSS文件到本地文件。如果指定的本地文件存在会覆盖,不存在则新建。
#  由本地文件路径加文件名包括后缀组成,例如/users/local/myfile.txt。
bucket.get_object_to_file('', '')


https://help.aliyun.com/document_detail/88442.html?spm=a2c4g.11186623.2.17.52f825d1vEuqMJ#concept-88442-zh


上一篇:python局域网内快速传文件
下一篇:结巴分词缓存预热及环境变量TMP查看

The minute you think of giving up, think of the reason why you held on so long.