|
|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package com.ruoyi.web.controller;
|
|
|
|
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaIgnore;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.ruoyi.common.annotation.Dev;
|
|
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
|
|
import com.ruoyi.common.core.domain.R;
|
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
|
@ -12,6 +14,9 @@ import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/")
|
|
|
|
|
@ -20,7 +25,7 @@ public class UploadController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/uploadKey")
|
|
|
|
|
public R uploadKey() {
|
|
|
|
|
public R uploadKey(){
|
|
|
|
|
return R.ok().setData(FileUtils.getUploadKey());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -31,7 +36,7 @@ public class UploadController {
|
|
|
|
|
if (ObjectUtil.isNull(file)) {
|
|
|
|
|
throw new ServiceException("文件为空");
|
|
|
|
|
}
|
|
|
|
|
return R.map().put("ossId", 0).put("url", fileService.setPrefix(pre).setKeepFilename().save(file));
|
|
|
|
|
return R.map().put("ossId",0).put("url",fileService.setPrefix(pre).setKeepFilename().save(file));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
|
|
|
|
|
@ -40,10 +45,10 @@ public class UploadController {
|
|
|
|
|
if (ObjectUtil.isNull(file)) {
|
|
|
|
|
throw new ServiceException("文件为空");
|
|
|
|
|
}
|
|
|
|
|
if (!file.getContentType().startsWith("image/")) {
|
|
|
|
|
if(!file.getContentType().startsWith("image/")){
|
|
|
|
|
throw new ServiceException("不是图片");
|
|
|
|
|
}
|
|
|
|
|
return R.map().put("ossId", 0).put("url", fileService.setPrefix(pre).setSize().setWatermark().setThumbnail().saveImage(file));
|
|
|
|
|
return R.map().put("ossId",0).put("url",fileService.setPrefix(pre).setSize().setWatermark().setThumbnail().saveImage(file));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|