zoukankan      html  css  js  c++  java
  • 2021 4 26

    阿里云oss学习:

    CreateBucketRequest createBucketRequest = new CreateBucketRequest("<bucketName>");
    
    // 指定Bucket的ACL权限。
    createBucketRequest.setBucketACL(CannedAccessControlList.PublicRead); 
    // 指定Bucket所在的数据中心。
    createBucketRequest.setLocationConstraint("oss-cn-hangzhou"); 
    
    // 异步创建存储空间。
    OSSAsyncTask createTask = oss.asyncCreateBucket(createBucketRequest, new OSSCompletedCallback<CreateBucketRequest, CreateBucketResult>() {
        @Override
        public void onSuccess(CreateBucketRequest request, CreateBucketResult result) {
            Log.d("asyncCreateBucket", "Success");
        }
        @Override
        public void onFailure(CreateBucketRequest request, ClientException clientException, ServiceException serviceException) {
            // 请求异常。
            if (clientException != null) {
                // 本地异常,如网络异常等。
                clientException.printStackTrace();
            }
            if (serviceException != null) {
                // 服务异常。
                Log.e("ErrorCode", serviceException.getErrorCode());
                Log.e("RequestId", serviceException.getRequestId());
                Log.e("HostId", serviceException.getHostId());
                Log.e("RawMessage", serviceException.getRawMessage());
            }
        }
    });
    GetBucketACLRequest getBucketACLRequest = new GetBucketACLRequest("<bucketName>");
    
    // 获取存储空间访问权限。
    OSSAsyncTask getBucketAclTask = oss.asyncGetBucketACL(getBucketACLRequest, new OSSCompletedCallback<GetBucketACLRequest, GetBucketACLResult>() {
        @Override
        public void onSuccess(GetBucketACLRequest request, GetBucketACLResult result) {
            Log.d("asyncGetBucketACL", "Success!");
            Log.d("BucketAcl", result.getBucketACL());
            Log.d("Owner", result.getBucketOwner());
            Log.d("ID", result.getBucketOwnerID());
        }
        @Override
        public void onFailure(GetBucketACLRequest request, ClientException clientException, ServiceException serviceException) {
            // 请求异常。
            if (clientException != null) {
                // 本地异常,如网络异常等。
                clientException.printStackTrace();
            }
            if (serviceException != null) {
                // 服务异常。
                Log.e("ErrorCode", serviceException.getErrorCode());
                Log.e("RequestId", serviceException.getRequestId());
                Log.e("HostId", serviceException.getHostId());
                Log.e("RawMessage", serviceException.getRawMessage());
            }
        }
    });
  • 相关阅读:
    MySQL错误 1030-Got error 28 from storage engine
    电脑开机无反应 不显示BIOS 硬件没问题
    python错误 import: unable to open X server
    Python 错误 invalid command 'bdist_wheel' & outside environment /usr
    Cento 7安装 Failed to execute /init
    笔记《鸟哥的Linux私房菜》5 首次登入与在线求助 man
    Scrapy XPath语法
    Linux 用户操作
    Mysql 表修改
    Ubuntu 配置 Python环境 IPython
  • 原文地址:https://www.cnblogs.com/fuxw4971/p/14910478.html
Copyright © 2011-2022 走看看