验证桶是否存在

Bucket是用于存储对象(Object)的容器,所有的对象都必须隶属于某个Bucket。本文介绍如何验证桶(Bucket)是否存在。

接口定义:

public boolean doesBucketExist(String bucketName)

参数:

参数名 类型 说明
bucketName String bucket名

代码示例:

    public void DoesBucketExist(String bucketName, OnS3ResponseListener<Boolean> listener){
        GlobalThreadPool.getInstance().execute(() -> {
            try {
                boolean exist = sS3Client.doesBucketExist(bucketName);

                Handler mainHandler = new Handler(Looper.getMainLooper());
                mainHandler.post(() -> listener.onResponse(exist));
            } catch (Exception e) {
                Handler mainHandler = new Handler(Looper.getMainLooper());
                mainHandler.post(() -> listener.onError());
            }
        });
    }