From 9c2489c0c360c8dda36d3cbe1dba79222096b2dd Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期一, 07 八月 2023 10:16:39 +0800
Subject: [PATCH] Merge branch 'master' into fly

---
 pkg/httpx/httpx.go |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/pkg/httpx/httpx.go b/pkg/httpx/httpx.go
index 94336ff..00ed1c4 100644
--- a/pkg/httpx/httpx.go
+++ b/pkg/httpx/httpx.go
@@ -5,6 +5,7 @@
 	"encoding/json"
 	"io/ioutil"
 	"net/http"
+	"os"
 	"time"
 )
 
@@ -39,3 +40,16 @@
 	}
 	return respBytes, nil
 }
+
+func GetMimeType(filePath string) string {
+	file, err := os.Open(filePath)
+	if err != nil {
+		return ""
+	}
+	buffer := make([]byte, 512)
+	_, _ = file.Read(buffer)
+	if len(buffer) == 0 {
+		return ""
+	}
+	return http.DetectContentType(buffer)
+}

--
Gitblit v1.8.0