/** * 从云端下载文件 * * @param fileName * @return */ @Override public InputStream download(String fileName) { if (BAIDU_BCS == null) { BAIDU_BCS = new BaiduBCS(new BCSCredentials(AK, SK), HOST); } GetObjectRequest request = new GetObjectRequest(BUCKET, fileName); BaiduBCSResponse<DownloadObject> response = BAIDU_BCS.getObject(request); DownloadObject downloadObject = response.getResult(); InputStream result = null; if (downloadObject != null) { result = downloadObject.getContent(); } return result; }
private static void getObjectWithDestFile(BaiduBCS baiduBCS, String object, File destFile) { GetObjectRequest getObjectRequest = new GetObjectRequest(AppAutoConstants.Baidu_BCS.bucket, object); baiduBCS.getObject(getObjectRequest, destFile); }