//minio文件批量上传
@Value("${minio.endpoint}")
private String ENDPOINT;
@Value("${minio.bucketName}")
private String BUCKETNAME;
@Value("${minio.accessKey}")
private String ACCESSKEY;
@Value("${minio.secretKey}")
private String SECRETKEY;
@PostMapping("minioUpload")
public Map<Object, String> upload(MultipartFile[] file) {
Map<Object,String> map = new HashMap<>();
String s=null;
try {
MinioClient minioClient = new MinioClient(ENDPOINT, ACCESSKEY, SECRETKEY);
//存入bucket不存在则创建,并设置为只读
if (!minioClient.bucketExists(BUCKETNAME)) {
minioClient.makeBucket(BUCKETNAME);
}
for(int i=0;i<file.length;i++){
String filename = file[i].getOriginalFilename();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// 文件存储的目录结构
String objectName = sdf.format(new Date()) ;
// 存储文件
minioClient.putObject(BUCKETNAME, objectName+ "/" + filename, file[i].getInputStream(), file[i].getContentType());
LOGGER.info("文件上传成功!");
s=ENDPOINT + "/" + BUCKETNAME + "/" + objectName/*+ "/" + filename*/;
map.put("bucket",objectName);
map.put("url",s);
}
}catch (Exception e) {
LOGGER.info("上传发生错误: {}!", e.getMessage());
}
return map;}
//获取文件信息
handleChange(file,fileList){
this.fileInfoList = fileList;
console.log(this.fileInfoList)
},
submitForm:function (){
this.fileInfoList.forEach((val,index) => {
formData.append("file",val.raw)
});
this.form.fileName = packetName
uploadVersion(formData).then(response =>{
console.log(response)
}