我正在尝试从 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());
}
最佳答案
object.getObjectContent()给出来自HTTP连接的数据流,从流中读取数据是否有异常?您也可以尝试 s3.getObjectAsString()
关于java - 如何使用 Java 将视频文件从 amazon s3 下载到特定文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42957678/