Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to calculate MD5 : AWS S3 bucket

I have my application hosted on AWS, Elastic Beanstalk - Tomcat 6. My data files are stored in an S3 bucket. When I am hosting my application on local server on my machine , I am able to read and write data to my S3 bucket (using via SDK), but from the application hosted on Elastic Beanstalk the writing operation is showing an error i.e on Elastic Beanstalk Tomcat. I am getting below error:

com.amazonaws.AmazonClientExceptio­n: Unable to calculate MD5 hash: visitorsinfo.json (No such file or directory)

I do have visitorsinfo.json in my S3 bucket which is successfully accessible from my local server in my machine, but not accessible from Elastic Beanstalk..

like image 756
user3112954 Avatar asked Oct 30 '22 20:10

user3112954


1 Answers

Instead of passing file object pass the Input Stream to the put object as shown below

InputStream is=file.getInputStream();                                                                           
s3client.putObject(new PutObjectRequest(bucketName, keyName,is,new ObjectMetadata())); 
like image 100
Amit Gujarathi Avatar answered Nov 15 '22 07:11

Amit Gujarathi