日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

Java管理LiveChannel

本文介紹Java SDK的LiveChannel常見操作,如創建LiveChannel、列舉LiveChannel及刪除LiveChannel等。

說明

本文示例由阿里云用戶bin提供,僅供參考。

部分示例需要用到fastjson,請在使用前在pom文件下配置相關依賴,配置信息如下。

<dependency>
  <groupId>com.alibaba</groupId>
  <artifactId>fastjson</artifactId>
  <version>1.2.54</version>
</dependency>

創建LiveChannel

通過RTMP協議上傳音視頻數據前,必須先調用該接口創建一個LiveChannel。調用PutLiveChannel接口會返回RTMP推流地址,以及對應的播放地址。

說明

您可以使用返回的地址進行推流、播放,您還可以根據該LiveChannel的名稱來發起相關的操作,如查詢推流狀態、查詢推流記錄、禁止推流等。

創建時如果已存在同名的LiveChannel,新創建的LiveChannel會覆蓋之前的,且新建的LiveChannel設置和狀態也會變成初始默認。

以下代碼用于創建LiveChannel。

import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*;
import java.util.List;
import com.aliyun.oss.common.auth.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 從環境變量中獲取訪問憑證。運行本代碼示例之前,請確保已設置環境變量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = "examplebucket";
        // 填寫LiveChannel名稱。
        String liveChannelName = "yourLiveChannelName";

        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);


        try {
            CreateLiveChannelRequest request = new CreateLiveChannelRequest(bucketName,
                    liveChannelName, "desc", LiveChannelStatus.Enabled, new LiveChannelTarget());
            CreateLiveChannelResult result = ossClient.createLiveChannel(request);

            //獲取推流地址。
            List<String> publishUrls = result.getPublishUrls();
            for (String item : publishUrls) {
                System.out.println(item);
            }

            //獲取播放地址。
            List<String> playUrls = result.getPlayUrls();
            for (String item : playUrls) {
                System.out.println(item);
            }

        } catch (OSSException oe) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

列舉LiveChannel

以下代碼用于列舉指定的LiveChannel。

import com.alibaba.fastjson.JSON;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*;
import com.aliyun.oss.common.auth.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 從環境變量中獲取訪問憑證。運行本代碼示例之前,請確保已設置環境變量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = "examplebucket";

        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);
        
        try {
            ListLiveChannelsRequest request = new ListLiveChannelsRequest(bucketName);
            LiveChannelListing liveChannelListing = ossClient.listLiveChannels(request);
            System.out.println(JSON.toJSONString(liveChannelListing));
        } catch (OSSException oe) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

刪除LiveChannel

說明
  • 當有客戶端正在向LiveChannel推流時,刪除請求會失敗。運行完畢未返回錯誤信息則代表刪除成功。

  • DeleteLiveChannel接口只會刪除LiveChannel本身,不會刪除推流生成的文件。

以下代碼用于刪除指定的LiveChannel。

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*;
import com.aliyun.oss.common.auth.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 從環境變量中獲取訪問憑證。運行本代碼示例之前,請確保已設置環境變量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = "examplebucket";
        // 填寫LiveChannel名稱。
        String liveChannelName = "yourLiveChannelName";

        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            LiveChannelGenericRequest request = new LiveChannelGenericRequest(bucketName, liveChannelName);
            ossClient.deleteLiveChannel(request);
        } catch (OSSException oe) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

設置LiveChannel狀態

以下代碼用于設置LiveChannel狀態,如果運行完畢為出現錯誤信息則表示設置成功。

import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*;
import com.aliyun.oss.common.auth.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 從環境變量中獲取訪問憑證。運行本代碼示例之前,請確保已設置環境變量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = "examplebucket";
        // 填寫LiveChannel名稱。
        String liveChannelName = "yourLiveChannelName";

        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            // 使用客戶端設置狀態,如需打開則配置為LiveChannelStatus.Enabled,如需關閉則配置為LiveChannelStatus.Disabled。
            ossClient.setLiveChannelStatus(bucketName, liveChannelName, LiveChannelStatus.Enabled);
        } catch (OSSException oe) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

獲取LiveChannel鑒權地址

以下代碼用于獲取LiveChannel鑒權地址。

import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*;
import java.util.List;
import com.aliyun.oss.common.auth.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 從環境變量中獲取訪問憑證。運行本代碼示例之前,請確保已設置環境變量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = "examplebucket";
        // 填寫LiveChannel名稱。
        String liveChannelName = "yourLiveChannelName";

        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            CreateLiveChannelRequest request = new CreateLiveChannelRequest(bucketName,
                    liveChannelName, "desc", LiveChannelStatus.Enabled, new LiveChannelTarget());
            CreateLiveChannelResult result = ossClient.createLiveChannel(request);

            // 獲取推流地址。
            List<String> publishUrls = result.getPublishUrls();
            for (String item : publishUrls) {
                // 獲取不包含簽名信息的推流地址。
                System.out.println(item);

                // 獲取包含簽名信息的推流地址。
                LiveChannelInfo liveChannelInfo = ossClient.getLiveChannelInfo(bucketName, liveChannelName);
                // expires表示過期時間,單位為Unix時間戳。本示例以設置過期時間為1小時為例。
                long expires = System.currentTimeMillis() / 1000 + 3600;
                // playlistName表示調用createLiveChannel接口時傳入的具體名稱。如果未傳入該參數,則默認值為"playlist.m3u8"。您也可以通過調用getLiveChannelInfo接口獲取該名稱。
                String signRtmpUrl = ossClient.generateRtmpUri(bucketName, liveChannelName, liveChannelInfo.getTarget().getPlaylistName(), expires);
                System.out.println(signRtmpUrl);
            }

            // 獲取播放地址。
            List<String> playUrls = result.getPlayUrls();
            for (String item : playUrls) {
                System.out.println(item);
            }
        } catch (OSSException oe) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

獲取LiveChannel狀態信息

以下代碼用于獲取指定LiveChannel的推流狀態信息。

import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*;
import com.aliyun.oss.common.auth.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 從環境變量中獲取訪問憑證。運行本代碼示例之前,請確保已設置環境變量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = "examplebucket";
        // 填寫LiveChannel名稱。
        String liveChannelName = "yourLiveChannelName";

        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            LiveChannelStat liveChannelStat = ossClient.getLiveChannelStat(bucketName, liveChannelName);
            System.out.println(liveChannelStat.toString());
        } catch (OSSException oe) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

獲取LiveChannel配置信息

以下代碼用于獲取指定LiveChannel的配置信息。

import com.alibaba.fastjson.JSON;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*;
import com.aliyun.oss.common.auth.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 從環境變量中獲取訪問憑證。運行本代碼示例之前,請確保已設置環境變量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = "examplebucket";
        // 填寫LiveChannel名稱。
        String liveChannelName = "yourLiveChannelName";

        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            LiveChannelInfo liveChannelInfo = ossClient.getLiveChannelInfo(bucketName, liveChannelName);
            System.out.println(JSON.toJSONString(liveChannelInfo));
        } catch (OSSException oe) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

生成LiveChannel播放列表

PostVodPlaylist接口用于為指定的LiveChannel生成一個點播用的播放列表。OSS會查詢指定時間范圍內由該LiveChannel推流生成的ts文件,并將其拼裝為一個m3u8播放列表。

以下代碼用于生成LiveChannel播放列表。

import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.aliyun.oss.common.auth.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 從環境變量中獲取訪問憑證。運行本代碼示例之前,請確保已設置環境變量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = "examplebucket";
        // 填寫LiveChannel名稱。
        String liveChannelName = "yourLiveChannelName";
        // 填寫PlayList名稱。
        String playListName = "yourPlayListName";


        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);
        // 查詢的起止時間區間,間隔不能大于24小時。
        long startTime = getUnixTimestamp("2019-06-27 23:00:00");
        long endTIme = getUnixTimestamp("2019-06-28 22:00:00");
        try {
            ossClient.generateVodPlaylist(bucketName, liveChannelName, playListName, startTime, endTIme);
        } catch (OSSException oe) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }

    private static long getUnixTimestamp(String time) {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date date = format.parse(time);
            return date.getTime() / 1000;
        } catch (ParseException e) {
            e.printStackTrace();
            return 0;
        }
    }
}

查看LiveChannel播放列表

以下代碼用于查看指定LiveChannel推流生成的且滿足指定時間段內的播放列表。

import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.OSSObject;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.aliyun.oss.common.auth.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 從環境變量中獲取訪問憑證。運行本代碼示例之前,請確保已設置環境變量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = "examplebucket";
        // 填寫LiveChannel名稱。
        String liveChannelName = "yourLiveChannelName";


        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);
        long startTime = getUnixTimestamp("2019-06-27 23:00:00");
        long endTIme = getUnixTimestamp("2019-06-28 22:00:00");
        try {
            OSSObject ossObject = ossClient.getVodPlaylist(bucketName, liveChannelName, startTime, endTIme);
            System.out.println(ossObject.toString());
        } catch (OSSException oe) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }

    private static long getUnixTimestamp(String time) {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date date = format.parse(time);
            return date.getTime() / 1000;
        } catch (ParseException e) {
            e.printStackTrace();
            return 0;
        }
    }
}

獲取LiveChannel推流記錄

GetLiveChannelHistory接口用于獲取指定LiveChannel的推流記錄。使用GetLiveChannelHistory接口最多會返回指定LiveChannel最近的10次推流記錄。

以下代碼用于獲取LiveChannel推流記錄。

import com.alibaba.fastjson.JSON;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.LiveRecord;
import java.util.List;
import com.aliyun.oss.common.auth.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 從環境變量中獲取訪問憑證。運行本代碼示例之前,請確保已設置環境變量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // 填寫Bucket名稱,例如examplebucket。
        String bucketName = "examplebucket";
        // 填寫LiveChannel名稱。
        String liveChannelName = "yourLiveChannelName";


        // 創建OSSClient實例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            List<LiveRecord> list = ossClient.getLiveChannelHistory(bucketName, liveChannelName);
            System.out.println(JSON.toJSONString(list));
        } catch (OSSException oe) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

相關文檔