aliyun.py: Add oss_delete and oss_list

This commit is contained in:
Fam Zheng 2025-02-15 11:47:54 +00:00
parent 072b36f38e
commit 09b0c326b5

View File

@ -20,6 +20,15 @@ def oss_get(name, bucket=None):
except oss2.exceptions.NoSuchKey:
return None
def oss_list(bucket):
ret = []
for obj in oss_bucket(bucket).list_objects().object_list:
ret.append(obj.key)
return ret
def oss_delete(name, bucket):
oss_bucket(bucket).delete_object(name)
def oss_sign_url(name, method='GET', bucket=None):
return oss_bucket(bucket).sign_url(method, name.encode(), 24 * 60 * 60)