mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	remove 删除 自带通用上传 接口 使用OSS模块替换
This commit is contained in:
		@@ -3,24 +3,16 @@ package com.ruoyi.web.controller.common;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import com.ruoyi.common.config.RuoYiConfig;
 | 
			
		||||
import com.ruoyi.common.constant.Constants;
 | 
			
		||||
import com.ruoyi.common.core.domain.AjaxResult;
 | 
			
		||||
import com.ruoyi.common.utils.file.FileUploadUtils;
 | 
			
		||||
import com.ruoyi.common.utils.file.FileUtils;
 | 
			
		||||
import com.ruoyi.framework.config.ServerConfig;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.http.MediaType;
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
import org.springframework.web.multipart.MultipartFile;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 通用请求处理
 | 
			
		||||
@@ -32,9 +24,6 @@ public class CommonController
 | 
			
		||||
{
 | 
			
		||||
    private static final Logger log = LoggerFactory.getLogger(CommonController.class);
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ServerConfig serverConfig;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通用下载请求
 | 
			
		||||
     *
 | 
			
		||||
@@ -67,30 +56,6 @@ public class CommonController
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通用上传请求
 | 
			
		||||
     */
 | 
			
		||||
    @PostMapping("/common/upload")
 | 
			
		||||
    public AjaxResult uploadFile(MultipartFile file) throws Exception
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            // 上传文件路径
 | 
			
		||||
            String filePath = RuoYiConfig.getUploadPath();
 | 
			
		||||
            // 上传并返回新文件名称
 | 
			
		||||
            String fileName = FileUploadUtils.upload(filePath, file);
 | 
			
		||||
            String url = serverConfig.getUrl() + fileName;
 | 
			
		||||
			Map<String,Object> ajax = new HashMap<>();
 | 
			
		||||
            ajax.put("fileName", fileName);
 | 
			
		||||
            ajax.put("url", url);
 | 
			
		||||
            return AjaxResult.success(ajax);
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
            return AjaxResult.error(e.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 本地资源通用下载
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user