x-file-storage icon indicating copy to clipboard operation
x-file-storage copied to clipboard

上传的文件 MD5 都一样

Open ion1ze opened this issue 7 months ago • 3 comments

调用方式如下:

@Operation(summary = "上传文件", description = "上传文件")
@PostMapping(value = "/file/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public Result<InfraFileUploadResponse> upload(@Parameter(description = "文件", required = true)
                                              @NotNull(message = "上传文件不能为空")
                                              @RequestParam MultipartFile file) {
    String date = DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd");
    String path = String.format(PATH_FORMAT, date);
    FileInfo fileInfo = this.fileStorageService.of(file)
            .setHashCalculatorMd5()
            .setPath(path)
            .upload();

    InfraFileUploadResponse data = InfraFileUploadResponse.from(fileInfo);
    log.info("MD5:{}", fileInfo.getHashInfo().getMd5());
    return Result.success("上传文件成功", data);
}

上传了几个不同的文件 Snipaste_2024-07-05_14-48-04

ion1ze avatar Jul 05 '24 06:07 ion1ze