-
Notifications
You must be signed in to change notification settings - Fork 253
上传文件接口支持自定义meta字段 #103
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
上传文件接口支持自定义meta字段 #103
Conversation
lianup
commented
Jan 12, 2022
- 增加uploadFile接口,支持自定义meta
- 去除comment_on_pr.yml
src/main/java/com/wechat/pay/contrib/apache/httpclient/WechatPayUploadHttpPost.java
Show resolved
Hide resolved
src/main/java/com/wechat/pay/contrib/apache/httpclient/WechatPayUploadHttpPost.java
Outdated
Show resolved
Hide resolved
src/main/java/com/wechat/pay/contrib/apache/httpclient/WechatPayUploadHttpPost.java
Outdated
Show resolved
Hide resolved
EmmetZC
left a comment
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.
LGTM
|
|
||
| public Builder(URI uri) { | ||
| if (uri == null) { | ||
| throw new IllegalArgumentException("缺少上传图片接口URL"); |
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.
用了File之后,不一定是图片了。
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.
已修改
src/main/java/com/wechat/pay/contrib/apache/httpclient/WechatPayUploadHttpPost.java
Show resolved
Hide resolved
| setFileContentType(fileName); | ||
| this.meta = String.format("{\"filename\":\"%s\",\"sha256\":\"%s\"}", fileName, fileSha256); | ||
| return this; | ||
| } |
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.
为什么不实现成
string meta = String.format("{\"filename\":\"%s\",\"sha256\":\"%s\"}", fileName, fileSha256);
return withFile(fileName, meta, inputStream);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.
从逻辑的角度,withImage调用wtihFile来实现更合理。已修改
|
|
||
| if (uri == null) { | ||
| throw new IllegalArgumentException("缺少上传图片接口URL"); | ||
| if (meta == null || meta.isEmpty()) { |
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.
这些检查还是需要吧,除了fileSha256之外。开发者要是忘记调用withFile()或者withImage()就调用build()是要报错的哦。请再参考标准的builder实现。
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.
现在虽然我们的设计meta就意味着有其他参数,但是未来可能放开了呢?
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.
有道理。之前没有考虑未来放开的场景,已修改。