zhangqian
2023-08-05 e581f6e6b410a6406a86c6743d43b8d450cd3d50
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)
}