NutzCN Logo
问答 富文本框的图片上传是上传到哪里?
发布于 1850天前 作者 qq_91afbf68 1456 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

我看到有最下面的那个,是上传到微信的吗?我返回了一个,但是会存在一个情况就是我返回的和那个下面返回的沟通在用img标签,

 @AdaptBy(type = UploadAdaptor.class, args = {"ioc:imageUpload"})
    @POST
    @At
    @Ok("json")
    @RequiresAuthentication
    @SuppressWarnings("deprecation")
    public Object uploadimage(@Param("Filedata") TempFile tf, HttpServletRequest req, AdaptorErrorContext err) {
        String wxid = Strings.sBlank(req.getSession().getAttribute("wxid"));
        NutMap nutMap = new NutMap();
        try {
            if (err != null && err.getAdaptorErr() != null) {
                nutMap.addv("state", "FAIL");
                return nutMap;
            } else if (tf == null) {
                nutMap.addv("state", "FAIL");
                return nutMap;
            } else {
                WxApi2 wxApi2 = wxConfigService.getWxApi2(wxid);
                WxResp resp = wxApi2.uploadimg(tf.getFile());
                if (resp.errcode() != 0) {
                    nutMap.addv("state", "FAIL");
                    return nutMap;
                }
                nutMap.addv("state", "SUCCESS");
                nutMap.addv("url", resp.get("url"));
                nutMap.addv("original", tf.getSubmittedFileName());
                nutMap.addv("type", tf.getSubmittedFileName().substring(tf.getSubmittedFileName().indexOf(".") + 1));
                nutMap.addv("size", tf.getSize());
  @Override
    public WxResp uploadimg(File f) {
        if (f == null)
            throw new NullPointerException("meida file is NULL");
        String url = String.format("https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=%s", getAccessToken());
        Request req = Request.create(url, METHOD.POST);
        req.getParams().put("media", f);
        Response resp = new FilePostSender(req).send();
        if (!resp.isOK())
            throw new IllegalStateException("uploadimg, resp code=" + resp.getStatus());
        return Json.fromJson(WxResp.class, resp.getReader("UTF-8"));
    }

就是会有这样的,怎么解?前面的那个是什么时候返回的

http://mmbiz.qpic.cn/mmbiz_png/oJSLQmDWypvD0FLwq4XQU8CrI0VUUMdN9cic7drXDuCLgPcOGhdN4EP1DhAuu2q9HrQPQHbKTkm9DMqgaW0kmZw/0,http://pp6etsnvk.bkt.clouddn.com/213391a3-1be7-4eb1-bb7b-64f5846e9ba7.jpg
1 回复

微信素材当然要上传到微信

添加回复
请先登陆
回到顶部