收藏
回答

我们小程序的用户图片都是直接上传到腾讯云的,还需要调用img_sec_check进行安全检测吗?

如果还是要检测,img_seq_check接口该怎么调用?不知道怎么设置media字段,可以给个样例吗?


回答关注问题邀请回答
收藏

2 个回答

  • 证爱网
    证爱网
    2019-09-26
        public String execute(CloseableHttpClient httpclient, String url, InputStream imgstream) throws IOException {
     
            HttpPost httpost = new HttpPost(url);
     
            HttpEntity entry = MultipartEntityBuilder
                    .create()
                    .addBinaryBody("media",imgstream)
                    .setMode(HttpMultipartMode.RFC6532)
                    .build();
            httpost.setEntity(entry);
     
            try (CloseableHttpResponse response = httpclient.execute(httpost)) {
                String responseContent = resputf8handle.handleResponse(response);
                //如果请求发生错误,抛出异常
                ObjectMapper mapper = new ObjectMapper();
                JsonNode node = mapper.readTree(responseContent);
                if (node.get("errcode") != null && !(node.get("errcode").asInt() == 0)) {
                    //WxError error = WxError.fromJson(responseContent);
                    //throw new Exception(responseContent);
                }
                return responseContent;
            }
        }
    }


    把网络图片读到InputStream并缩放到1000x1000以下尺寸,然后用上面代码Post,得到下面错误:

    RetryExec.java:97) I/O exception (java.net.SocketException) caught when processing request to {s}->https://api.weixin.qq.com:443: Connection reset by peer: socket write error

    还缺什么吗?


    2019-09-26
    有用
    回复
  • 扶苏。
    扶苏。
    2019-09-25


    Java代码片段

    2019-09-25
    有用
    回复
登录 后发表内容
问题标签