日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

根據文件后綴名稱獲取contentType,其中Minio上傳文件會用到contentType

作者:明快de玄米61 更新時間: 2023-07-07 編程語言

代碼:

import org.springframework.http.MediaType;
import org.springframework.http.MediaTypeFactory;

public class Test {

    public static void main(String[] args) {
        String fileName = "1.docx";
        String contentType = MediaTypeFactory.getMediaType(fileName).orElse(MediaType.APPLICATION_OCTET_STREAM).toString();
        System.out.println("文件名稱為“" + fileName + "”的contentType:" + contentType);
    }
}

結果:

文件名稱為“1.docx”的contentType:application/vnd.openxmlformats-officedocument.wordprocessingml.document

原文鏈接:https://blog.csdn.net/qq_42449963/article/details/129799820

  • 上一篇:沒有了
  • 下一篇:沒有了
欄目分類
最近更新