Jersey Multipart文件下载客户端中的mimexxx.tmp文件;文件夹
我的要求是使用REST API从服务器下载大文件,我将Java与泽西岛框架和Multipart_form_data类型一起发送和接收文件。 API工作正常,但是当我执行reverse..ReadEntity(formDatamultipart.Class)
时,问题在客户端,它将在Java的“ Java.io.io.tmpdir”文件夹中复制整个多部分数据。是否有任何方法可以避免它或任何API/配置来更改泽西岛多部分临时目录路径(“ Java.io.tmpdir”除外)。 以下是我的示例客户端代码:
Invocation.Builder invocationBuilder = webTarget.request(MediaType.MULTIPART_FORM_DATA_TYPE);
Response response = invocationBuilder.get();
FormDataMultiPart objMultiPart = response.readEntity(FormDataMultiPart.class);
List<BodyPart> listBodyPart = objMultiPart.getBodyParts();
try(FileOutputStream out = new FileOutputStream(filePath.toFile(), true)){
for(BodyPart part : listBodyPart) {
//code to process each bodypart
}
}
My requirement is to download large file from server using rest API, I am using java with Jersey framework and MULTIPART_FORM_DATA type for sending and receiving the file. API is working fine, but the problem is at client side when I do response.readEntity(FormDataMultiPart.class)
it copies the entire multipart data in java's "java.io.tmpdir" folder. Is there any way to avoid it or any api/configuration to change jersey multipart temp directory path (other than "java.io.tmpdir").
Below is my sample client code:
Invocation.Builder invocationBuilder = webTarget.request(MediaType.MULTIPART_FORM_DATA_TYPE);
Response response = invocationBuilder.get();
FormDataMultiPart objMultiPart = response.readEntity(FormDataMultiPart.class);
List<BodyPart> listBodyPart = objMultiPart.getBodyParts();
try(FileOutputStream out = new FileOutputStream(filePath.toFile(), true)){
for(BodyPart part : listBodyPart) {
//code to process each bodypart
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论