I have written AWS Lambda code where I need to store an image in /tmp location of aws lambda. Below is my code:
String fileLocation = "loc1/loc2/";
String imageNameWithoutExt = "image1";
//creating directories first below storing the image
boolean status = new File("/tmp/"+fileLocation).mkdirs();
if(status == true){
File targetFile = File.createTempFile(imageNameWithoutExt,".jpg",new File("/tmp/"+fileLocation));
FileOutputStream outStream = new FileOutputStream(targetFile);
outStream.write(buffer);
outStream.close();
}else{
System.out.println("unable to create directory inside /tmp/");
}
And in response, it is printing the else statement:
unable to create directory inside /tmp/
What modification I need to make to write and read the files from /tmp location. Any help would be appreciated.