upload media
This commit is contained in:
parent
bc5999ba6f
commit
d7d4c2e3f4
|
@ -115,7 +115,28 @@ func (o *OaSdk) UploadFileByByte(file []byte, ext string) (string, string, error
|
|||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
res, err := http.Post(UploadOaMedia, writer.FormDataContentType(), body)
|
||||
token, err := o.getAccessToken()
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
postType := ""
|
||||
if ext == ".jpg" || ext == ".png" || ext == ".gif" || ext == ".jpeg" {
|
||||
postType = "image"
|
||||
} else if ext == ".mp4" {
|
||||
postType = "video"
|
||||
} else if ext == ".mp3" {
|
||||
postType = "voice"
|
||||
}
|
||||
|
||||
if postType == "" {
|
||||
return "", "", fmt.Errorf("不支持的文件类型")
|
||||
}
|
||||
|
||||
res, err := http.Post(
|
||||
fmt.Sprintf("%s?access_token=%s&type=%s", UploadOaMedia, token, postType),
|
||||
writer.FormDataContentType(),
|
||||
body,
|
||||
)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue