|
@@ -89,15 +89,33 @@ func (w *WeWorkMsgAuditClient) GetMsgAuditContent(seq, limit uint64, timeout int
|
|
|
list = append(list, msg)
|
|
|
}else if chatInfo.Type == "file" {
|
|
|
file, err := chatInfo.GetFileMessage()
|
|
|
+ sdkFileID := file.File.SdkFileID
|
|
|
if err != nil {
|
|
|
utils.FileLog.Info(fmt.Sprintf("查询文件消息类型失败:%v \n", err))
|
|
|
errMsg = errors.New("企业微信 查询文件消息类型失败:"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
+ isFinish := false
|
|
|
+ buffer := bytes.Buffer{}
|
|
|
+ indexBuf := ""
|
|
|
+ for !isFinish {
|
|
|
+ //获取媒体数据
|
|
|
+ mediaData, err := client.GetMediaData(indexBuf, sdkFileID, "", "", 5)
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("媒体数据拉取失败:%v \n", err))
|
|
|
+ errMsg = errors.New("企业微信 媒体数据拉取失败:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ buffer.Write(mediaData.Data)
|
|
|
+ if mediaData.IsFinish {
|
|
|
+ isFinish = mediaData.IsFinish
|
|
|
+ }
|
|
|
+ indexBuf = mediaData.OutIndexBuf
|
|
|
+ }
|
|
|
// 保存文件到本地
|
|
|
filePath, _ := os.Getwd()
|
|
|
filePath = path.Join(filePath, file.File.FileName+"."+file.File.FileExt)
|
|
|
- err := ioutil.WriteFile(filePath, file.File.Data, 0666)
|
|
|
+ err = ioutil.WriteFile(filePath, buffer.Bytes(), 0666)
|
|
|
if err != nil {
|
|
|
utils.FileLog.Info(fmt.Sprintf("文件存储失败:%v \n", err))
|
|
|
errMsg = errors.New("企业微信 文件存储失败:"+err.Error())
|