一、官方接口文档
aliyun oss
二、实例操作
1. 获取特定文件夹下的文件数量
import oss2
auth = oss2.Auth('keyid', 'secret')
bucket = oss2.Bucket(auth, 'endpoint', 'bucket名称')
res = 0
for obj in oss2.ObjectIterator(bucket, prefix = '文件名'):
res += 1
print(res)
2. 获取特定文件夹的大小,平均文件大小
import oss2
auth = oss2.Auth('keyid', 'secret')
bucket = oss2.Bucket(auth, 'endpoint', 'bucket名称')
res = 0
length = 0
for obj in oss2.ObjectIterator(bucket, prefix = '文件名'):
res += 1
length += obj.size
print('directory: 文件名' + ' length:' + str(length / 1024 / 1024) + "MB")
print('the number of file: ' + str(res))
print('average length: ' + str(length/res/1024/1024) + "MB")