美文网首页
配置本地文件上传路径,达到文件服务器的效果

配置本地文件上传路径,达到文件服务器的效果

作者: 枯萎天然呆 | 来源:发表于2023-10-18 16:40 被阅读0次
package com.ruoyi.framework.config;

import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 通用配置
 * 
 * @author ruoyi
 */
@Configuration
public class ResourcesConfig implements WebMvcConfigurer
{
    @Autowired
    private RepeatSubmitInterceptor repeatSubmitInterceptor;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)
    {
        /*        Constants.RESOURCE_PREFIX + "/**":这个路径模式表示所有以/resource/开头的请求都会被映射到本地文件系统。
         addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"):指定了这些静态资源在本地文件系统中的位置。RuoYiConfig.getProfile()获取了配置中的文件上传路径。
         举例来说,如果Constants.RESOURCE_PREFIX是/resource,而RuoYiConfig.getProfile()返回的是/uploads,那么访问/resource/image.jpg将会映射到本地文件系统的/uploads/image.jpg。*/
        /** 本地文件上传路径 */
        //public static final String RESOURCE_PREFIX = "/resource";
        registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**")
                .addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");

    }

  
}

相关文章

  • springboot文件上传MultipartFile Fi

    文件上传到本地服务器(liunx,windows)都可以 记得给路径哦 效果如图所示 public JSONObj...

  • Spring boot 基于ajax 文件上传下载

    1.配置静态文件访问路径 2.配置文件上传大小 3.多文件上传接口,下载文件接口 4.文件上传工具类 5.文件上传页面

  • 配置WebDav-macOS

    系统macOS Big Sur系统版本11.6.5 1.文件服务器,使用http协议上传和下载文件2.配置webD...

  • centos搭建es

    使用命令上传本地文件到centos scp 本地文件路径 username@ip:/path输入密码完成 给用户...

  • nginx文件目录服务器

    用nginx配置一个文件服务器,并解决中文乱码问题,配置文件 如果,开放目录,当时不允许直接访问,只能访问指定路径...

  • 上传文件

    1:配置setting的设置2:定义上传文件的入口3:定义处理上传文件的view函数4:配置路径url 当 Dja...

  • 本地文件上传和文件上传文件服务器

    1:(本地上传)tomcat 设置虚拟路径upload 以http://ip:port/upload 访问对应的...

  • springboot访问图片本地路径并映射成url

    springboot访问图片本地路径并映射成url1.配置文件配置 =======================...

  • Mac本地文件上传到云服务器

    一、put命令 1、put 本地文件路径 远程路径 二、scp命令 1、mac上传文件到Linux服务器scp 文...

  • nodejs12

    文件上传 文件上传时,存放在绝对路径下,而返回的时候,返回的是访问路径。 使用配置文件,方便图片位置的改变 mon...

网友评论

      本文标题:配置本地文件上传路径,达到文件服务器的效果

      本文链接:https://www.haomeiwen.com/subject/bvjcidtx.html