简体   繁体   English

正在从tomcat服务下载部分文件

[英]Partial file is being downloaded from tomcat service

I'm trying to download a file of size 50mb in the browser (chrome) using rest api of service running in tomcat. 我正在尝试使用在tomcat中运行的服务的剩余api在浏览器(chrome)中下载大小为50mb的文件。 In the server I'm using httpservletresponse's output stream to write the file contents. 在服务器中,我正在使用httpservletresponse的输出流来写入文件内容。 Sometime, only partial file is being downloaded (less than 50MB) even though server returns 200 response code. 有时,即使服务器返回了200个响应代码,也仅下载了部分文件(小于50MB)。

Here are my question, 这是我的问题,

  1. Does server response 200 indicates successful file download or it just indicates that my request was processed and it has nothing to do with complete file download. 服务器响应200是表示文件下载成功还是仅表示我的请求已处理,与完整文件下载无关。 Or server should return different status code if file is downloaded partially. 如果文件已部分下载,则服务器应返回不同的状态代码。
  2. What could be reasons for partial file download. 可能是部分文件下载的原因。

Response 200 is the standard response for successful HTTP requests . 响应200是成功HTTP 请求的标准响应。 The actual response depends on the request's content (and method as well); 实际响应取决于请求的内容(以及方法)。 in your case it means that the server understood your request, which you're authorized to submit and successfully completed its task (which seems to be sending the file). 在您的情况下,这意味着服务器理解了您的请求,您已被授权提交并成功完成了它的任务(似乎正在发送文件)。

Possible errors are many: an error in reading the file (have you checked that it is readable?), an error in your application not returning the correct response size and so on... 可能的错误有很多:读取文件时发生错误(是否检查了文件的可读性?),应用程序中的错误未返回正确的响应大小等等……

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM