我正在开发一个应用程序,我想在mongodb中存储文件路径以进行重试和删除过程,因此需要以下帮助:
@Async
public void uploadFileToS3Bucket(MultipartFile multipartFile, boolean enablePublicReadAccess, Documents document) {
String fileName = multipartFile.getOriginalFilename();
try {
// creating the file in the server (temporarily)
File file = new File(fileName);
FileOutputStream fos = new FileOutputStream(file);
fos.write(multipartFile.getBytes());
fos.close();
System.out.println("upload drs *****");
// storing file into Amazon S3 Bucket
PutObjectRequest putObjectRequest = new PutObjectRequest(this.awsS3AudioBucket, fileName, file);
if (enablePublicReadAccess) {
putObjectRequest.withCannedAcl(CannedAccessControlList.PublicRead);
System.out.println("upload drs 1111*****");
// Path filePath = this.paths.resolve(fileName).normalize();
}
this.amazonS3.putObject(putObjectRequest);
System.out.println("upload drs2222 *****");
documentService.save(document);