func getFileContentType(file string) (string, error) {
	pFle, er := os.Open(file)
	if er != nil {
		fmt.Println(er)
	}
	defer func() {
		if err := pFle.Close(); err != nil {
			fmt.Println(err)
		}
	}()
	buffer := make([]byte, 512)
	_, err := pFle.Read(buffer)
	if err != nil {
		return "", err
	}
	contenttype := http.DetectContentType(buffer)
	return contenttype, nil
}
注:要设置文件下载的文件名,需要做如下处理,不然都是download
	    c.Header("Content-Type", contenttype)
			 c.Header("content-Disposition", fmt.Sprintf("attachment;filename=%s", fileToDownload))