package com.starry.common.utils.file;

import java.util.Objects;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author admin 文件上传工具类
 * @since 2022/10/28
 */
public class FileUploadUtils {

    /**
     * 默认大小 50M
     */
    public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024;

    /**
     * 默认的文件名最大长度 100
     */
    public static final int DEFAULT_FILE_NAME_LENGTH = 100;

    public static String upload(String baseDir, MultipartFile file, String[] allowedExtension) {
        int fileNameLength = Objects.requireNonNull(file.getOriginalFilename()).length();
        if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) {
            throw new RuntimeException("文件名超过默认的最大长度");
        }
        return null;
    }

}
