From 8387019f75afd65435f9e30bdbd365bb7bcc025c Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Mon, 5 Sep 2022 14:30:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?update:=E4=BC=98=E5=8C=96=20ContentType=20?= =?UTF-8?q?=E7=9A=84=E8=AF=86=E5=88=AB=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/xuyanwu/spring/file/storage/FileStorageService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-file-storage/src/main/java/cn/xuyanwu/spring/file/storage/FileStorageService.java b/spring-file-storage/src/main/java/cn/xuyanwu/spring/file/storage/FileStorageService.java index f6728799..492b74b5 100644 --- a/spring-file-storage/src/main/java/cn/xuyanwu/spring/file/storage/FileStorageService.java +++ b/spring-file-storage/src/main/java/cn/xuyanwu/spring/file/storage/FileStorageService.java @@ -101,7 +101,8 @@ public FileInfo upload(UploadPretreatment pre) { } else if (pre.getFileWrapper().getContentType() != null) { fileInfo.setContentType(pre.getFileWrapper().getContentType()); } else { - fileInfo.setContentType(URLConnection.guessContentTypeFromName(fileInfo.getFilename())); + String contentType = URLConnection.guessContentTypeFromName(fileInfo.getFilename()); + fileInfo.setContentType(contentType != null ? contentType : "application/octet-stream"); } byte[] thumbnailBytes = pre.getThumbnailBytes(); @@ -112,7 +113,8 @@ public FileInfo upload(UploadPretreatment pre) { } else { fileInfo.setThFilename(fileInfo.getFilename() + pre.getThumbnailSuffix()); } - fileInfo.setThContentType(URLConnection.guessContentTypeFromName(fileInfo.getThFilename())); + String contentType = URLConnection.guessContentTypeFromName(fileInfo.getThFilename()); + fileInfo.setThContentType(contentType != null ? contentType : "application/octet-stream"); } FileStorage fileStorage = getFileStorage(pre.getPlatform()); From 32b7918aaa0f2460b05a9b898b2b8763c8eecd4a Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Mon, 5 Sep 2022 14:48:27 +0800 Subject: [PATCH 2/2] Release 0.6.1 --- docs/_navbar.md | 3 ++- "docs/\346\233\264\346\226\260\350\256\260\345\275\225.md" | 4 ++++ pom.xml | 2 +- spring-file-storage-test/pom.xml | 4 ++-- spring-file-storage/pom.xml | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/_navbar.md b/docs/_navbar.md index 9f44941e..2499dd8a 100644 --- a/docs/_navbar.md +++ b/docs/_navbar.md @@ -1,5 +1,6 @@ -* 文档版本 0.6.0 +* 文档版本 0.6.1 + * [0.6.1](https://spring-file-storage.xuyanwu.cn/0.6.1/) * [0.6.0](https://spring-file-storage.xuyanwu.cn/0.6.0/) * [0.5.0](https://spring-file-storage.xuyanwu.cn/0.5.0/) * [0.4.0](https://spring-file-storage.xuyanwu.cn/0.4.0/) diff --git "a/docs/\346\233\264\346\226\260\350\256\260\345\275\225.md" "b/docs/\346\233\264\346\226\260\350\256\260\345\275\225.md" index 540eb1c3..b49c1378 100644 --- "a/docs/\346\233\264\346\226\260\350\256\260\345\275\225.md" +++ "b/docs/\346\233\264\346\226\260\350\256\260\345\275\225.md" @@ -1,5 +1,9 @@ # 更新记录 +## 0.6.1 +2022-09-05 +- 优化 ContentType 的识别方式 + ## 0.6.0 2022-08-17 - 增加对 FTP 的支持 diff --git a/pom.xml b/pom.xml index 00123260..467b45b2 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ cn.xuyanwu spring-file-storage-parent pom - 0.6.0 + 0.6.1 spring-file-storage-parent A File Storage Service diff --git a/spring-file-storage-test/pom.xml b/spring-file-storage-test/pom.xml index 964afc81..ef28429e 100644 --- a/spring-file-storage-test/pom.xml +++ b/spring-file-storage-test/pom.xml @@ -12,7 +12,7 @@ cn.xuyanwu spring-file-storage-test - 0.6.0 + 0.6.1 spring-file-storage-test spring-file-storage 的测试和演示模块 @@ -116,7 +116,7 @@ cn.xuyanwu spring-file-storage - 0.6.0 + 0.6.1 diff --git a/spring-file-storage/pom.xml b/spring-file-storage/pom.xml index 446ce7c6..038dcade 100644 --- a/spring-file-storage/pom.xml +++ b/spring-file-storage/pom.xml @@ -5,7 +5,7 @@ spring-file-storage-parent cn.xuyanwu - 0.6.0 + 0.6.1 4.0.0