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
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());