文件上传流从哪里获取内容? [英] Where do file upload streams get the content from?

查看:183
本文介绍了文件上传流从哪里获取内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于文件上传的问题,这与它的工作原理有关,而不是代码问题。我在互联网上查看,但找不到合适的答案。

I have a question regarding file upload, which is more related to how it works rather than a code issue. I looked on the internet, but I couldn't find a proper answer.

我有一个在tomcat上运行的Web应用程序,它处理文件上传(通过servlet)。假设我现在要上传大文件(> 1 Gb)。我的理解是,一旦实际传输了整个文件,HTTP请求的多部分内容就可以在我的servlet中使用。

I have a web application running on tomcat, which handles file uploads (through a servlet). Let's say I want now to upload huge files (> 1 Gb). My understading was that the multipart content of the HTTP request was available in my servlet once the whole file was actually transfered.

我的问题是请求的内容实际存储在哪里?当一个人调用 HttpServletRequest.getParts() Part InputStream c $ c>对象。但是,从哪里读取流? Tomcat会将它存储在某个地方吗?

My question is where the content of the request is actually stored ? When one calls HttpServletRequest.getParts() an InputStream is available on the Part object. However, where is the stream reading from ? Does Tomcat store it somewhere ?

我想这可能不够清楚,所以我会根据你的意见更新帖子,如果有的话。

I guess this might not be clear enough, so I'll update the post according to your comments, if any.

谢谢

推荐答案

Tomcat商店部分 s在X:\ some \ path \Tomcat 7.0 \ temp(/some/path/apache-tomcat-7.0.x/temp)目录中。

Tomcat stores Parts in "X:\some\path\Tomcat 7.0\temp" (/some/path/apache-tomcat-7.0.x/temp) directory.

解析多部分请求时,如果单个部分的大小超过阈值,则为该部分创建临时文件。

when a multipart request is parsed, if the size of a single part exceed a threshold, a temporary file is created for that part.

您的servlet / jsp将在所有部分的转移完成后调用。

your servlet/jsp will be invoked when transfer of all parts has been completed.

当请求被销毁时,所有临时文件也将被删除。

when the request is destroyed all temporary files are deleted as well.

如果您对多部分解析阶段感兴趣,请查看apache commons-fileupload(特别是 ServletFileUpload.parseRequest()),tomcat基于a变体

if you are interested in the multipart parse phase, take a look at apache commons-fileupload (specifically ServletFileUpload.parseRequest()), tomcat is based on a variant of that

更新

您可以将其配置为java arg,即在windows中:

you can configure it as a java arg, ie in windows:

这篇关于文件上传流从哪里获取内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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