aa
This commit is contained in:
@@ -150,14 +150,14 @@ func getBoundary() (boundary string) {
|
||||
return boundary
|
||||
}
|
||||
|
||||
func (a *API) AccessAPIUpload(data []byte, fileName, contentType string) (retVal map[string]interface{}, err error) {
|
||||
func (a *API) AccessAPIUpload(url string, data []byte, fileName, contentType, materialType string) (retVal map[string]interface{}, err error) {
|
||||
params2 := make(map[string]interface{})
|
||||
accessToken := a.CBGetToken()
|
||||
if accessToken == "" {
|
||||
panic("token is empty!")
|
||||
}
|
||||
params2["access_token"] = accessToken
|
||||
fullURL := utils.GenerateGetURL(prodURL, "cgi-bin/media/uploadimg", params2)
|
||||
fullURL := utils.GenerateGetURL(prodURL, url, params2)
|
||||
// baseapi.SugarLogger.Debug(fullURL)
|
||||
// 实例化multipart
|
||||
body := &bytes.Buffer{}
|
||||
@@ -173,7 +173,9 @@ func (a *API) AccessAPIUpload(data []byte, fileName, contentType string) (retVal
|
||||
// 写入文件数据到multipart,和读取本地文件方法的唯一区别
|
||||
_, err = part.Write(data)
|
||||
//将额外参数也写入到multipart
|
||||
//_ = writer.WriteField("media", fileName)
|
||||
if materialType != "" {
|
||||
_ = writer.WriteField("type", materialType)
|
||||
}
|
||||
err = writer.Close()
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
|
||||
Reference in New Issue
Block a user