python 对象存储OSS 阿里云

Posted gloria11

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 对象存储OSS 阿里云相关的知识,希望对你有一定的参考价值。

SDK参考 -》python->上传文件-》简单上传

 

 

#  -*- coding: utf-8 -*-

import oss2

 

auth=oss2.Auth(‘<yourAccessKeyID>‘,‘<yourAccessKeySecret>‘)

bucket = oss2.Bucket(auth,‘http://oss-cn-hangzhou.aliyuncs.com‘,‘<yourBucketName>‘)

#必须以二进制的方式打开文件,因为需要知道文件包含的字节数

with open(‘<yourLocalFile>‘,‘rb‘) as fileobj:

    fileobj.seek(1000,os.SEEK_SET)

   current =fileobj.tell()

   bucket.put_object(‘<yourObjectName>‘,fileobj)

 

以上是关于python 对象存储OSS 阿里云的主要内容,如果未能解决你的问题,请参考以下文章