use of com.zyd.blog.plugin.file.GlobalFileUploader in project OneBlog by zhangyd-c.
the class BizFileServiceImpl method upload.
@Override
@Transactional(rollbackFor = Exception.class)
public int upload(MultipartFile[] file) {
if (null == file || file.length == 0) {
throw new GlobalFileException("请至少选择一张图片!");
}
for (MultipartFile multipartFile : file) {
FileUploader uploader = new GlobalFileUploader();
uploader.upload(multipartFile, FileUploadType.COMMON.getPath(), true);
}
return file.length;
}
use of com.zyd.blog.plugin.file.GlobalFileUploader in project OneBlog by zhangyd-c.
the class BizFileServiceImpl method remove.
@Override
@Transactional(rollbackFor = Exception.class)
public void remove(Long[] ids) {
for (Long id : ids) {
File oldFile = this.getByPrimaryKey(id);
this.removeByPrimaryKey(id);
try {
FileUploader uploader = new GlobalFileUploader();
uploader.delete(oldFile.getFilePath(), oldFile.getUploadType());
} catch (Exception ignored) {
}
}
}
use of com.zyd.blog.plugin.file.GlobalFileUploader in project OneBlog by zhangyd-c.
the class RestApiController method uploadFileForMd.
@BussinessLog("simpleMD编辑器中上传文件")
@RequiresPermissions("article:publish")
@PostMapping("/uploadFileForMd")
public Object uploadFileForMd(@RequestParam("file") MultipartFile file) {
FileUploader uploader = new GlobalFileUploader();
VirtualFile virtualFile = uploader.upload(file, FileUploadType.SIMPLE.getPath(), true);
Map<String, Object> resultMap = new HashMap<>(3);
resultMap.put("success", 1);
resultMap.put("message", "上传成功");
resultMap.put("filename", virtualFile.getFullFilePath());
return resultMap;
}
Aggregations