use of org.jeecg.modules.oss.entity.OSSFile in project kms by mahonelau.
the class SysUploadController method uploadMinio.
/**
* 上传
* @param request
*/
@PostMapping(value = "/uploadMinio")
public Result<?> uploadMinio(HttpServletRequest request) {
Result<?> result = new Result<>();
String bizPath = request.getParameter("biz");
if (oConvertUtils.isEmpty(bizPath)) {
bizPath = "";
}
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
// 获取上传文件对象
MultipartFile file = multipartRequest.getFile("file");
// 获取文件名
String orgName = file.getOriginalFilename();
orgName = CommonUtils.getFileName(orgName);
String file_url = MinioUtil.upload(file, bizPath);
if (oConvertUtils.isEmpty(file_url)) {
return Result.error("上传失败,请检查配置信息是否正确!");
}
// 保存文件信息
OSSFile minioFile = new OSSFile();
minioFile.setFileName(orgName);
minioFile.setUrl(file_url);
ossFileService.save(minioFile);
result.setMessage(file_url);
result.setSuccess(true);
return result;
}
use of org.jeecg.modules.oss.entity.OSSFile in project kms by mahonelau.
the class OSSFileServiceImpl method upload.
@Override
public void upload(MultipartFile multipartFile) throws IOException {
String fileName = multipartFile.getOriginalFilename();
fileName = CommonUtils.getFileName(fileName);
OSSFile ossFile = new OSSFile();
ossFile.setFileName(fileName);
String url = OssBootUtil.upload(multipartFile, "upload/test");
// update-begin--Author:scott Date:20201227 for:JT-361【文件预览】阿里云原生域名可以文件预览,自己映射域名kkfileview提示文件下载失败-------------------
// 返回阿里云原生域名前缀URL
ossFile.setUrl(OssBootUtil.getOriginalUrl(url));
// update-end--Author:scott Date:20201227 for:JT-361【文件预览】阿里云原生域名可以文件预览,自己映射域名kkfileview提示文件下载失败-------------------
this.save(ossFile);
}
use of org.jeecg.modules.oss.entity.OSSFile in project kms by mahonelau.
the class OSSFileController method queryById.
/**
* 通过id查询.
*/
@ResponseBody
@GetMapping("/queryById")
public Result<OSSFile> queryById(@RequestParam(name = "id") String id) {
Result<OSSFile> result = new Result<>();
OSSFile file = ossFileService.getById(id);
if (file == null) {
result.error500("未找到对应实体");
} else {
result.setResult(file);
result.setSuccess(true);
}
return result;
}
use of org.jeecg.modules.oss.entity.OSSFile in project kms by mahonelau.
the class OSSFileController method delete.
@ResponseBody
@DeleteMapping("/delete")
public Result delete(@RequestParam(name = "id") String id) {
Result result = new Result();
OSSFile file = ossFileService.getById(id);
if (file == null) {
result.error500("未找到对应实体");
} else {
boolean ok = ossFileService.delete(file);
if (ok) {
result.success("删除成功!");
}
}
return result;
}
use of org.jeecg.modules.oss.entity.OSSFile in project jeecg-boot by jeecgboot.
the class OSSFileServiceImpl method upload.
@Override
public void upload(MultipartFile multipartFile) throws IOException {
String fileName = multipartFile.getOriginalFilename();
fileName = CommonUtils.getFileName(fileName);
OSSFile ossFile = new OSSFile();
ossFile.setFileName(fileName);
String url = OssBootUtil.upload(multipartFile, "upload/test");
// update-begin--Author:scott Date:20201227 for:JT-361【文件预览】阿里云原生域名可以文件预览,自己映射域名kkfileview提示文件下载失败-------------------
// 返回阿里云原生域名前缀URL
ossFile.setUrl(OssBootUtil.getOriginalUrl(url));
// update-end--Author:scott Date:20201227 for:JT-361【文件预览】阿里云原生域名可以文件预览,自己映射域名kkfileview提示文件下载失败-------------------
this.save(ossFile);
}
Aggregations