文件上传获取文件的contentType

    xiaoxiao2021-12-03  17

    public static String getMimeType(String filePath) throws Exception

    {

    if(filePath == null && filePath.equals(""))

    {

    throws new Exception("filePath is null or empty");

    }

    Path tmpPath = Paths.get(filePath);

    String contentType =  Files.probeContentType(tmpPath);

    if(contentType == null && contentType.equals(""))

    {

    contentType = "application/octet-stream";

    }

    return contentType;

    }

    转载请注明原文地址: https://ju.6miu.com/read-679874.html

    最新回复(0)