|
|
@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import com.ruoyi.common.config.Global;
|
|
|
|
import com.ruoyi.common.config.Global;
|
|
|
|
import com.ruoyi.common.config.ServerConfig;
|
|
|
|
import com.ruoyi.common.config.ServerConfig;
|
|
|
|
|
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
@ -88,4 +89,24 @@ public class CommonController
|
|
|
|
return AjaxResult.error(e.getMessage());
|
|
|
|
return AjaxResult.error(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 本地资源通用下载
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@GetMapping("/common/download/resource")
|
|
|
|
|
|
|
|
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
|
|
|
|
|
|
|
throws Exception
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// 本地资源路径
|
|
|
|
|
|
|
|
String localPath = Global.getProfile();
|
|
|
|
|
|
|
|
// 数据库资源地址
|
|
|
|
|
|
|
|
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
|
|
|
|
|
|
|
// 下载名称
|
|
|
|
|
|
|
|
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
|
|
|
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
|
|
|
|
response.setContentType("multipart/form-data");
|
|
|
|
|
|
|
|
response.setHeader("Content-Disposition",
|
|
|
|
|
|
|
|
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
|
|
|
|
|
|
|
|
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|