我正在尝试从S3帐户下载一个视频文件。它不是给我一个错误,我也看不到下载的文件意味着我没有得到文件的位置。我怀疑是我的文件是下载。请给出一个解决方案。谢谢提前这里是我的代码:
System.out.println("Downloading an object");
S3Object object = s3.getObject(new GetObjectRequest(bucketName, key));
System.out.println("Content-Type: " + object.getObjectMetadata().getContentType());
object.getObjectContent();
}catch(AmazonServiceException ex){
System.out.println("Caught an AmazonServiceException, which means your request made it "
+ "to Amazon S3, but was rejected with an error response for some reason.");
System.out.println("Error Message: " + ex.getMessage());
System.out.println("HTTP Status Code: " + ex.getStatusCode());
System.out.println("AWS Error Code: " + ex.getErrorCode());
System.out.println("Error Type: " + ex.getErrorType());
System.out.println("Request ID: " + ex.getRequestId());
}catch (AmazonClientException ace) {
System.out.println("Caught an AmazonClientException, which means the client encountered "
+ "a serious internal problem while trying to communicate with S3, "
+ "such as not being able to access the network.");
System.out.println("Error Message: " + ace.getMessage());
}
答案 0 :(得分:0)
object.getObjectContent()给出来自HTTP连接的数据流,是否有从流中读取的异常?你也可以尝试s3.getObjectAsString()