I am trying to download a video file from S3 account.It is niether giving me an error nor I am able to see the file downloaded means I am not getting the location of file.I have a doubt that is my file is getting downloaded.Pls give a solution on this.Thanks in advance here is my code:
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() gives the stream of data from the HTTP connection, is there any exception reading from the stream? you can also try s3.getObjectAsString()