使用http协议,java和javascript下载大文件> 1GB [英] Download large file >1GB using http protocol, java and javascript

查看:190
本文介绍了使用http协议,java和javascript下载大文件> 1GB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于下载文件的Web应用程序。一切正常,除非我想下载超过1GB的文件。

I have a web application for downloading files. Everything works fine except when I want to download a file more than 1GB .

这是我的java代码:

This is my java code:

InputStream in = new FileInputStream(new File(folderFile.getAbsolutePath()));
                org.apache.commons.io.IOUtils.copy(in, response.getOutputStream());
                response.flushBuffer();
                in.close();

HTTP请求:

$http({
            method:'get',
            url:this.apiDownloadFileUrl,
            responseType:'arraybuffer',
            cache: false
    });

这是客户端:我在客户端成功获取数据,但当我制作数据时Blob,如果数据大小超过500MB,则没有发生任何事情且未下载。另外,我可以下载300MB ...

and here is client side: I got data successfully on client, but when I make it Blob , if the data size was more than 500MB , nothing happened and it wasn't downloaded. Also, I can download 300MB ...

如何检查是内存问题还是服务器问题? ...当我从gmail下载时,我可以下载超过1GB。

How can I check if it is a memory problem, or a server problem? ... When I download from gmail , I can download more than 1GB .

            .success(function(databack) {       
                            var file = new Blob([ databack ], {
                                type : 'application/csv'
                            });

                            var fileURL = window.URL.createObjectURL(file);
                            var a = document.createElement('a');
                            a.href = fileURL;
                            a.target = '_blank';
                            a.download = data;
                            document.body.appendChild(a);
                            a.click(); 


推荐答案

您是否尝试过使用 copyLarge()方法?对于复制()遇到JavaDoc说:

Have you tried using the copyLarge() methods from IOUtils? For the copy() methods the JavaDoc says:


对于大型流,使用copyLarge(InputStream,OutputStream)方法。

"For large streams use the copyLarge(InputStream, OutputStream) method."

这篇关于使用http协议,java和javascript下载大文件> 1GB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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