在客户端接收多部分响应(ClosableHttpResponse)

在客户端接收多部分响应(ClosableHttpResponse),第1张

在客户端接收多部分响应(ClosableHttpResponse)

我终于有了解决方法。

我将使用javax邮件MimeMultipart。

以下是该解决方案的代码片段:-

    ByteArrayDataSource datasource = new ByteArrayDataSource(in, "multipart/form-data");    MimeMultipart multipart = new MimeMultipart(datasource);    int count = multipart.getCount();    log.debug("count " + count);    for (int i = 0; i < count; i++) {        BodyPart bodyPart = multipart.getBodyPart(i);        if (bodyPart.isMimeType("text/plain")) { log.info("text/plain " + bodyPart.getContentType()); processTextData(bodyPart.getContent());        } else if (bodyPart.isMimeType("application/octet-stream")) { log.info("application/octet-stream " + bodyPart.getContentType()); processBinaryData(bodyPart.getInputStream()));        } else { log.warn("default " + bodyPart.getContentType());        }    }

请让我知道是否还有其他标准解决方案。



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5487792.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-12
下一篇2022-12-12

发表评论

登录后才能评论

评论列表(0条)

    保存