# -*- coding: utf-8 -*- import oss2, uuid def oss(img_key, img_path): auth = oss2.Auth('LTA。。。。。。', '3XkJh。。。。。。') endpoint = 'http://oss-cn-qingdao.aliyuncs.com' bucket = oss2.Bucket(auth, endpoint, 'dasheng1104') bucket.put_object_from_file(img_key, img_path) if __name__=="__main__": img_key = str(uuid.uuid4()) + '.jpg' img_path = '/Users/kunlun/Downloads/purchase_process_1.png' oss(img_key, img_path) print "upload success!"
###
auth = oss2.Auth('<yourAccessKeyId>', '<yourAccessKeySecret>')
bucket = oss2.Bucket(auth, '
http://oss-cn-qingdao.aliyuncs.com', '<yourBucketName>')
- img_key = str(uuid.uuid4()) + '.jpg' 为了不让其重复