Closed ponponon closed 1 year ago
Use stat_object()
API
Use
stat_object()
API
One problem with stat_object is that it reports S3Error when the object doesn't exist.
from minio.error import S3Error
def object_exist(file_path: str) -> bool:
try:
client.stat_object(bucket,file_path)
return True
except Exception as error:
if 'code: NoSuchKey' in str(error):
return False
else:
raise error
So every time I call stat_object, I need to use try ... except ...
I would like to have a function that returns a bool, but the current minio python sdk doesn't have such a convenient function.
Is it possible to provide such a function? I can provide PR
This is the only way as per S3 specifications and we have no plans to add a wrapper to stat_object() for this purpose.
I googled 「"python" "minio" determines whether an object exists」 and couldn't find an answer. minio is a full-fledged object store, it can't even have a basic API, right?