文件上传端点需要关闭InputStream吗? [英] File upload endpoint need to close InputStream?

查看:81
本文介绍了文件上传端点需要关闭InputStream吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/upload")
public String upload(@FormDataParam("file") InputStream inputStream) {
    ...
    inputStream.close(); // necessary?
}

对于接受文件输入的API端点,我们需要手动关闭InputStream还是框架为我们完成了此任务?

For an API endpoint that accepts a file input, do we need to manually close the InputStream or does the framework do it for us?

我检查了 Jersey文档,但找不到任何文档信息.

I have checked the Jersey docs but could not find any information about it.

寻找可靠的来源或通过某种方式对其进行验证.

Looking for credible source or some way to validate it.

推荐答案

关闭InputStream是您的责任.

It is your responsibility to close InputStream.

Jersey本质上不知道何时关闭流.

Jersey intrinsically cannot know when to close your stream.

这篇关于文件上传端点需要关闭InputStream吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆