描述
Python 使用阿里的SDK向阿里OSS上传图片
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| import oss2 import os import sys
auth = oss2.Auth('ID', '密钥')
bucket = oss2.Bucket(auth, 'https://oss-cn-shanghai.aliyuncs.com', 'bzjh') with open('D:\\collection\\1.png', 'rb') as fileobj: fileobj.seek(1000, os.SEEK_SET) current = fileobj.tell() bucket.put_object_from_file('Typora_img/2.png', 'D:\\collection\\1.png')
|