Skip to content
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

Closed
wants to merge 6 commits into from
Closed

新增支持流的形式上传方式 #781

wants to merge 6 commits into from

Conversation

oah8
Copy link
Contributor

@oah8 oah8 commented Jul 11, 2024

No description provided.

@houseme
Copy link
Collaborator

houseme commented Jul 11, 2024

please fix ci

和这个 #780 改的是一个地方吗?

@oah8
Copy link
Contributor Author

oah8 commented Jul 11, 2024

please fix ci

和这个 #780 改的是一个地方吗?

对的,我改了支持流或文件的形式都可

@houseme
Copy link
Collaborator

houseme commented Jul 16, 2024

辛苦 更新一下 @oah8

@oah8
Copy link
Contributor Author

oah8 commented Jul 16, 2024

辛苦 更新一下 @oah8

@oah8
Copy link
Contributor Author

oah8 commented Jul 16, 2024

辛苦 更新一下 @oah8

你好,请问我是要修复一下和v2之前修改的冲突问题还是上传附件资源uploadAttachment这个 @houseme

@houseme
Copy link
Collaborator

houseme commented Jul 17, 2024

辛苦合并一下主分支的代码,不然一直存在下面截图里的情况
image

@oah8
Copy link
Contributor Author

oah8 commented Jul 17, 2024

辛苦合并一下主分支的代码,不然一直存在下面截图里的情况 image

好,我感觉有点问题我这边改改再合并😄

# Conflicts:
#	officialaccount/material/material.go
#	util/http.go
@oah8
Copy link
Contributor Author

oah8 commented Jul 18, 2024

辛苦合并一下主分支的代码,不然一直存在下面截图里的情况 image

麻烦 code review下

@@ -102,7 +102,8 @@ func (security *Security) ImageCheckV1(filename string) (err error) {
}

uri := fmt.Sprintf(imageCheckURL, accessToken)
Copy link
Collaborator

@houseme houseme Jul 19, 2024

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
Copy link
Collaborator

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filename 改成 directory 的意义是什么?或出发点是什么呢?

Copy link
Contributor Author

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
}

// 获取文件名
Copy link
Collaborator

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)
Copy link
Collaborator

@houseme houseme Jul 19, 2024

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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

辛苦根据提示修改一下 Invalid

Copy link
Collaborator

@houseme houseme left a 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"`
Copy link
Collaborator

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

介绍一下这个代码删除的原因是什么?

@houseme
Copy link
Collaborator

houseme commented Jul 22, 2024

建议,1、整理一下代码,2、重新创建一个分支来处理一下逻辑,因为目前 Pr 删除了一些主分支的代码了。

@oah8
Copy link
Contributor Author

oah8 commented Jul 22, 2024

建议,1、整理一下代码,2、重新创建一个分支来处理一下逻辑,因为目前 Pr 删除了一些主分支的代码了。

好👌

@oah8 oah8 closed this by deleting the head repository Jul 22, 2024
@oah8
Copy link
Contributor Author

oah8 commented Jul 24, 2024

建议,1、整理一下代码,2、重新创建一个分支来处理一下逻辑,因为目前 Pr 删除了一些主分支的代码了。

你好,我新建了分支并提交了,麻烦看下
image
这个图片的错误是要更新依赖吗

@houseme
Copy link
Collaborator

houseme commented Jul 24, 2024

上面是提示需要格式化代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants