oss2罗列所有文件

使用oss python sdk罗列某目录下所有文件。

#!/usr/bin/python3

import sys, os
import oss2

auth = oss2.Auth('keyID', 'keySecret')
bucket = oss2.Bucket(auth, 'url', 'bucket', enable_crc=False)

is_truncated = True
next_marker = ''
while(is_truncated):
    result = bucket.list_objects(prefix="", marker=next_marker, max_keys=1000)
    is_truncated = result.is_truncated
    next_marker = result.next_marker
    oss_objects = result.object_listfor oss_object in oss_objects:
        print('find: ' + oss_object.key)
原文地址:https://www.cnblogs.com/pinganzi/p/10190983.html