use of com.zyd.blog.file.entity.VirtualFile in project OneBlog by zhangyd-c.
the class SysConfigServiceImpl method saveFile.
@Override
@RedisCache(flush = true, enable = false)
public void saveFile(String key, MultipartFile file) {
if (key == null) {
return;
}
if (file != null) {
FileUploader uploader = new GlobalFileUploader();
VirtualFile virtualFile = uploader.upload(file, FileUploadType.QRCODE.getPath(), true);
this.saveConfig(key, virtualFile.getFullFilePath());
}
}
use of com.zyd.blog.file.entity.VirtualFile 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;
}
use of com.zyd.blog.file.entity.VirtualFile in project OneBlog by zhangyd-c.
the class BaseFileUploader method saveFile.
VirtualFile saveFile(VirtualFile virtualFile, boolean save, String uploadType) {
if (save) {
BizFileService fileService = SpringContextHolder.getBean(BizFileService.class);
try {
SysConfigService configService = SpringContextHolder.getBean(SysConfigService.class);
Map<String, Object> config = configService.getConfigs();
String storageType = (String) config.get(ConfigKeyEnum.STORAGE_TYPE.getKey());
BizFile fileInfo = BeanConvertUtil.doConvert(virtualFile, BizFile.class);
User sessionUser = SessionUtil.getUser();
fileInfo.setUserId(null == sessionUser ? null : sessionUser.getId());
fileInfo.setUploadType(uploadType);
fileInfo.setStorageType(storageType);
fileService.insert(new File(fileInfo));
} catch (Exception e) {
e.printStackTrace();
}
}
return virtualFile;
}
use of com.zyd.blog.file.entity.VirtualFile in project OneBlog by zhangyd-c.
the class GlobalFileUploader method upload.
@Override
public VirtualFile upload(MultipartFile file, String uploadType, boolean save) {
ApiClient apiClient = this.getApiClient(uploadType);
VirtualFile virtualFile = apiClient.uploadImg(file);
return this.saveFile(virtualFile, save, uploadType);
}
use of com.zyd.blog.file.entity.VirtualFile in project OneBlog by zhangyd-c.
the class GlobalFileUploader method upload.
@Override
public VirtualFile upload(File file, String uploadType, boolean save) {
ApiClient apiClient = this.getApiClient(uploadType);
VirtualFile virtualFile = apiClient.uploadImg(file);
return this.saveFile(virtualFile, save, uploadType);
}
Aggregations