Open
Description
`func Download(clt *core.Client, mediaId, filepath string) (written int64, err error) {
file, err := os.Create(filepath)
if err != nil {
return
}
defer func() {
file.Close()
if err != nil {
os.Remove(filepath)
}
}()
return DownloadToWriter(clt, mediaId, file)
}如上例,根据mediaId下载多媒体到文件,但微信的消息中,除了语音消息,其他多媒体消息是未知文件扩展名的,目前认为,可以根据mediaId获取文件扩展名的方法就是调用微信获取素材的API,其返回的HTTP头中含有文件扩展名(如jpeg):
HTTP/1.1 200 OK
Connection: close
Content-Type: image/jpeg
Content-disposition: attachment; filename="MEDIA_ID.jpg"
Date: Sun, 06 Jan 2013 10:20:18 GMT
Cache-Control: no-cache, must-revalidate
Content-Length: 339721
curl -G "https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID"`
但是这样意味着需要额外的调用,请问大家有遇到类似的问题吗?是怎么解决的?
Metadata
Metadata
Assignees
Labels
No labels