使用 HttpURLConnection 下载文件只能下载到 1G

查看 46|回复 2
作者:caihp   
现在有个需求是通过后台下载文件,下载大于 1G 的文件的时候下到 1G 就会报 SocketException:Connection reset 或者 SocketException:Time out, 请问这个应该是哪里的大小限制住了
下载的代码如下:
HttpURLConnection httpConn = null;
URL url = new URL(Splitter.on("?").splitToList(file.getFileUrl()).get(0));
httpConn = (HttpURLConnection) url.openConnection();
httpConn.connect();
InputStream is = httpConn.getInputStream();
zos.putNextEntry(new ZipEntry(folderName + "/" + file.getName()));
int length;
while ((length = is.read(buffer)) > 0) {
zos.write(buffer, 0, length);
}
is.close();

url, length, 下载, zos

salmon5   
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_max_temp_file_size
tanranran   
和 HttpURLConnection 无关,应该是后端有限制,检查下后端网关的配置
您需要登录后才可以回帖 登录 | 立即注册

返回顶部