我想通过另一种方法使用此端点上传文件名
@PostMapping("/uploadFile")
public UploadFileResponse uploadFile(@RequestParam("file") MultipartFile
file) {
String fileName = fileStorageService.storeFile(file);
String fileDownloadUri =
ServletUriComponentsBuilder.fromCurrentContextPath()
.path("/downloadFile/")
.path(fileName)
.toUriString();
return new UploadFileResponse(UUID.randomUUID(), fileName, fileDownloadUri, file.getContentType(), file.getSize());
}
另一种方法是将文件名和一些数据发送到mongodb中。
@PostMapping("/uploadPath")
public String setPath(@RequestBody Image image ) {
image.setImageId(UUID.randomUUID());
String fileName = m.
image.setFileName(fileName);
String filePath = Paths.get(fileStorageProperties.getUploadDir()).toAbsolutePath().normalize()+File.separator+fileName;
image.setImagePath(filePath);
imgserv.insertPath(image);
}
是否可以从endppoint(/ uploadFile)访问文件名并使用端点(/ uploadPath)存储在数据库中