<pre name="code" class="python"># -*- coding: utf-8 -*-
"""
wrapper of oss2.
"""
import oss2
from PwLogging import PwLogging
class OSS2(object):
def __init__(self, accesskeyid, accesskeysecret, endpoint, bucket, logger=None):
self.accessid = accesskeyid
self.accesskey = accesskeysecret
self.endpoint = endpoint
self.bucketstring = bucket
self.logger = logger
self.connection()
def connection(self):
try:
auth = oss2.Auth(self.accessid, self.accesskey)
self.bucket = oss2.Bucket(auth, self.endpoint, self.bucketstring)
except Exception, e:
self.logger.error(e)
def uploadFiles(self, remotepath, localpath, filenamelist):
try:
faildlist = []
for file in filenamelist:
result = self.bucket.put_object_from_
阿里云OSS 上传文件 删除文件自封装 —python
最新推荐文章于 2024-06-09 23:31:01 发布
该博客介绍了如何使用Python对阿里云OSS服务进行文件上传和删除操作,提供了自封装的代码示例,并分享了源代码链接。
摘要由CSDN通过智能技术生成