下载管理器下载文件超过210 GB [英] DownloadManager downloading files over 2.1 GB

查看:201
本文介绍了下载管理器下载文件超过210 GB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个应用程序以及我工作的一个特点是下载一些二进制文件。其中有些是真正的大(超过数兆字节)。下载的精细完成,只要文件大小不超过2 GB。

I am working on an app and one of the features I am working on is to download some binary files. Some of them are really big (more than several mega-bytes). Downloads are completing fine as long as the file size is less than 2 GB.

我被困在一个文件,该文件是3.2GB的,我得到进度更新(我汇集下载管理器的最新进展),但下载完成后,该文件是不是在目标文件路径present。讯问的下载管理器该下载ID,我得到<一href="http://developer.android.com/reference/android/app/DownloadManager.html#STATUS_FAILED"><$c$c>STATUS_FAILED和原因<一href="http://developer.android.com/reference/android/app/DownloadManager.html#ERROR_UNKNOWN"><$c$c>ERROR_UNKNOWN - 最喜爱的错误的详细信息人会希望有

I got stuck on a file that is 3.2GB in that I get progress updates (I am pooling the DownloadManager for progress updates), but when the download completes, the file is not present on the target file path. Interrogating the DownloadManager for that download id, I get STATUS_FAILED and reason ERROR_UNKNOWN - the favorite error details one will ever wish for!

什么是奇怪的是,这似乎在大多数的设备,但对于一些(如三星SG 4主动OS 4.2.2和LG的Nexus 5 OS 4.4.2),它不会出现。

What is weird is that this appears on most of the devices, but for some (like Samsung SG 4 Active OS 4.2.2 and LG Nexus 5 OS 4.4.2), it doesn't appear.

做一些额外的调查,我发现,这似乎是在错误安卓下载管理器实施。看来Android的实现存储的下载次数为int,但是当数必须高于 Integer.MAX_VALUE的在下载结束为失败。

Doing some extra investigation, I found out that this seems to be a bug in Android DownloadManager implementation. It seems Android implementation stores the download count as an int, but when that count goes above Integer.MAX_VALUE the download ends as failed.

我想,以取代下载管理器用法与前台服务,但我不会轻言放弃......

I am thinking to replace the DownloadManager usage with a foreground service, but I wouldn't give up yet ....

难道你们面对这个,如果是这样,你怎么解决? 是否有$ P $任何变通使用下载管理器 P-4.2.2这样我就可以每个文件下载超过2.1 GB?

Did you guys face this and if so, how did you fix it? Is there any work-around to use DownloadManager in pre-4.2.2 so I can download more than 2.1 GB per file?

推荐答案

要下载这么大的文件,你需要下载那些块。或者您可以使用支持HTTP范围内选择任何库,允许拉下来的多件单个文件,支持恢复等。

To download such a large files, you need to download those in chunks. Either you can use any library that support HTTP range options to allow to pull down a single file in multiple pieces , supporting resume etc.

或者你可以分割你的服务器上的大文件,然后与MD5哈希每个文件,文本文件,当您第一次开始下载,然后拿到MD5文件一旦完成,然后检查散列相匹配的下载件。如果他们不那么删除的那件,并将其添加到队列下载的项目。

Or you can split your large file on your server then have a text file with MD5 hash of each file, when you first start to download then get the MD5 file once finish then check that hashes matches the downloaded pieces. If they do not then delete that piece and add it to queue of items to download.

在所有作品下载和MD5的作品,你可以把碎片重新走到一起为单个文件。

Once all pieces downloaded and MD5 works, you can put the pieces back together as single file.

如果你正在考虑下载该文件的SD卡,然后FAT32是默认的文件系统。有每个文件限制为4 GB的文件系统。

If you are thinking to download the file in the SD card then FAT32 is the default file system. There is a 4 GB per file limit with this file system.

这篇关于下载管理器下载文件超过210 GB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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