Browse Source

下载文件到时候如果文件名为空,需要输出故障信息

Signed-off-by: allan716 <[email protected]>
allan716 3 years ago
parent
commit
e408536f1a
1 changed files with 6 additions and 1 deletions
  1. 6 1
      internal/pkg/my_util/util.go

+ 6 - 1
internal/pkg/my_util/util.go

@@ -79,6 +79,11 @@ func DownFile(urlStr string, _reqParam ...types.ReqParam) ([]byte, string, error
 		return nil, "", err
 	}
 	filename := GetFileName(resp.RawResponse)
+
+	if filename == "" {
+		log_helper.GetLogger().Errorln("DownFile.GetFileName is string.empty", urlStr)
+	}
+
 	return resp.Body(), filename, nil
 }
 
@@ -91,7 +96,7 @@ func GetFileName(resp *http.Response) string {
 	re := regexp.MustCompile(`filename=["]*([^"]+)["]*`)
 	matched := re.FindStringSubmatch(contentDisposition)
 	if matched == nil || len(matched) == 0 || len(matched[0]) == 0 {
-		//fmt.Println("######")
+		log_helper.GetLogger().Errorln("GetFileName.Content-Disposition", contentDisposition)
 		return ""
 	}
 	return matched[1]