Above image shows the structure of my application deployment..
Spring boot application have the below aws configuration.
The application is working on local. I can able to write file to s3 bucket. when i deploy the code on different server as i mentioned above image .Its failed to write s3 bucket Showing below error
Error while uploading the file to S3java.io.FileNotFoundException: sample.txt (Permission denied)"
Note: These servers are in different location.
How can i overcome this issue. I have a solution
- Write upload file to UI Server folder and using a script to upload in the s3 Anyone have other solution please suggest.
Edit 1: 1.I can able to receive request form UI server.but file is not present in the request 2.other get request are working Edit 2
Controller
@PostMapping("/request")
ReturnStatus saveRequest(HttpServletRequest request,
@RequestParam(value = "file", required = true)
MultipartFile uploadedFile) throws InvalidInputException {
AuthDto auth = (AuthDto) request.getAttribute(AUTH_DTO);
return requestService.saveRequest(
new RequestParams( uploadedFile));
}
Service Class Logic
File uploadFile = convertMultiPartToFile(params.getLookUpValues());
s3ClientBuilder.build().putObject(new PutObjectRequest(s3BucketName, fileName, uploadFile));
public static File convertMultiPartToFile(MultipartFile file) throws IOException {
File convFile = new File(file.getOriginalFilename());
FileOutputStream fos = new FileOutputStream(convFile);
fos.write(file.getBytes());
fos.close();
return convFile;
}
Edit 3
create a temp folder inside the UI server tomcat
Once i click on upload file saved to temp and request goes to elastic beanstalk and save the meta data.
How the s3 bucket file upload work?
Need to write any separate script? if yes how its trigger
Pease correct me if am wrong