package com.gree.mall.miniapp.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.MultipartConfigElement;

@Configuration
public class MulitpartConfig {

    @Value("${spring.profiles.active}")
    private String env;
    /**
     * 文件上传临时路径
     */
    @Bean
    MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        if (env.equals("prd")) {
            factory.setLocation("/home/jsmapp");
        } else {
            factory.setLocation("/app");
        }
        return factory.createMultipartConfig();
    }

}
