-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
新增支持流的形式上传方式 #781
新增支持流的形式上传方式 #781
Conversation
please fix ci 和这个 #780 改的是一个地方吗? |
对的,我改了支持流或文件的形式都可 |
辛苦 更新一下 @oah8 |
好 |
…feature_add_stream_upload # Conflicts: # officialaccount/material/media.go
# Conflicts: # officialaccount/material/material.go # util/http.go
…feature_add_stream_upload
@@ -102,7 +102,8 @@ func (security *Security) ImageCheckV1(filename string) (err error) { | |||
} | |||
|
|||
uri := fmt.Sprintf(imageCheckURL, accessToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
104-106 合并定义
var(
uri = fmt.Sprintf(imageCheckURL, accessToken)
directory = filename
response, err = util.PostFile("media", nil, "", directory, uri)
)
@@ -212,7 +212,8 @@ func (csm *Manager) UploadHeadImg(kfAccount, fileName string) (err error) { | |||
} | |||
uri := fmt.Sprintf("%s?access_token=%s&kf_account=%s", customerServiceUploadHeadImg, accessToken, kfAccount) | |||
var response []byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -163,7 +164,7 @@ type resAddMaterial struct { | |||
} | |||
|
|||
// AddMaterialFromReader 上传永久性素材(处理视频需要单独上传),从 io.Reader 中读取 | |||
func (material *Material) AddMaterialFromReader(mediaType MediaType, filename string, reader io.Reader) (mediaID string, url string, err error) { | |||
func (material *Material) AddMaterialFromReader(mediaType MediaType, directory string, reader io.Reader) (mediaID string, url string, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filename
改成 directory
的意义是什么?或出发点是什么呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我是在开发企业微信客服发送消息上传临时素材获取media_id时,看上传都是以本地临时文件夹形式上传的,然后想改下可以通过流或文件传输,然后就增加了Directory字段,filename只是文件名,为了和永久素材做区分。新人第一次看开源的,可能有点菜 😭
@@ -229,12 +230,14 @@ func (material *Material) AddVideoFromReader(filename, title, introduction strin | |||
if err != nil { | |||
return | |||
} | |||
|
|||
// 获取文件名 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
233-250 合并一下
response []byte | ||
) | ||
if response, err = util.PostJSON(uri, msg); err != nil { | ||
uri := fmt.Sprintf("%s?access_token=%s", templateSendURL, accessToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当时这样改的出发点是什么,可以分享一下不?前一个同学把这类型定义都合并了,现在又拆开了,想了解一下,您这边拆分的出发点是什么,咱们可以取其优点在代码编写中,感谢
util/http.go
Outdated
fileContent = data | ||
isFile = false | ||
} else { | ||
return nil, fmt.Errorf("Invalid argument: required stream data and filename or only directory") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
辛苦根据提示修改一下 Invalid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uploadAttachment
is unused (deadcode) 根据提示处理一下
var ( | ||
msg = struct { | ||
ShortID string `json:"template_id_short"` | ||
KeyNameList []string `json:"keyword_name_list"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyNameList 是上一个 pr #783 添加的参数,确定一下是否要删除呢?
@@ -190,19 +190,6 @@ func PostFileFromReader(filedName, directory, uri string, reader io.Reader) ([]b | |||
return PostMultipartForm(fields, uri) | |||
} | |||
|
|||
// PostFileFromReader 上传文件,从 io.Reader 中读取 | |||
func PostFileFromReader(filedName, fileName, uri string, reader io.Reader) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
介绍一下这个代码删除的原因是什么?
建议,1、整理一下代码,2、重新创建一个分支来处理一下逻辑,因为目前 Pr 删除了一些主分支的代码了。 |
好👌 |
上面是提示需要格式化代码 |
No description provided.