文档中心 > 列举文件
列举文件

最近更新时间:2022-07-25

本文介绍如何列举文件。

代码如下:

from src.ossConfig import ossConfig
import unicloud_oss.Oss as Oss

access_key = 'youraccesskey'
secret_key = 'yoursecretkey'
endpoint_url = 'http://XXXXXXXXXXXXXXXXX.com'
config = ossConfig(access_key,secret_key,endpoint_url)

bucket_name = 'test1'

objects = Oss.list_objects(config, bucket_name)
if objects is not None:
   # List the object names
   for obj in objects:
       print(obj["Key"])
else:
   print("ERROR!")