最近打算将原始的公共账号重构成小程序,就打算用现成的框架去做,原生的样式太少,用现成的UI框架,更方便点
@ApiOperation(value = "上传单张图片", notes = "fileType 1:art 2:temp ")
@RequestMapping(value = "upload_img", method = RequestMethod.POST)
public Object uploadImg(@ApiParam(value = "file", required = true, name = "file")
@RequestParam("file")
MultipartFile file) {
String fileName = "";
try {
fileName = file.getOriginalFilename();//默认null
MinioClient minioClient = new MinioClient("http://127.0.0.1", 9000, "minioadmin", "minioadmin", "", false);
boolean isExist = minioClient.bucketExists("datas");
if (isExist) {
System.out.println("Bucket already exists.");
} else {
// Make a new bucket called asiatrip to hold a zip file of photos.
minioClient.makeBucket("datas");
}
// Upload the zip file to the bucket with putObject
// 创建对象
minioClient.putObject("datas", fileName, file.getInputStream(), null);
String url = minioClient.getObjectUrl("datas", fileName);
return successResponse(url);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
return unSuccessResponse("");
}
}
minio的安装网上有教程