fix(biji): 修复图片上传和预览相关问题
-优化图片预览接口返回信息,提高错误处理的可读性- 在图片上传时添加基础 URL,确保正确的图片路径 - 更新 Vite 配置,修复开发环境的代理设置
This commit is contained in:
@@ -64,12 +64,14 @@ public class ImageController {
|
||||
public void preview(@PathVariable String url, HttpServletResponse resp) throws IOException {
|
||||
if (StrUtil.isBlank(url)) {
|
||||
resp.setStatus(404);
|
||||
R.fail("文件不存在");
|
||||
resp.getWriter().write("{\"code\":404,\"msg\":\"文件不存在\",\"data\":null}");
|
||||
return;
|
||||
}
|
||||
File file = new File(rootPath + File.separator + url);
|
||||
if (!file.exists()) {
|
||||
resp.setStatus(404);
|
||||
R.fail("文件不存在");
|
||||
resp.getWriter().write("{\"code\":404,\"msg\":\"文件不存在\",\"data\":null}");
|
||||
return;
|
||||
}
|
||||
String contentTypeFromFileExtension = getContentTypeFromFileExtension(url);
|
||||
// 设置正确的 MIME
|
||||
|
||||
Reference in New Issue
Block a user