DownloadManager downloading files over 2.1 GB

gunar

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.

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!

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.

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 ....

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?

Ajay S

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.

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.

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

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Downloading files >3Gb from S3 fails with "SocketTimeoutException: Read timed out"

From Dev

Fiddlercore x-replywithfile over 2gb

From Dev

Lotusscript function FileLen returns negative long for files over 2 GB

From Dev

Phpseclib sftp put runs out of memory with 1 GB+ files

From Dev

file is not downloading via DownloadManager in Android

From Dev

Streaming large files (>2GB over IIS) using WebAPI

From Dev

downloading files over the internet, if the component has been selected (WITH Inno Tools Downloader)

From Dev

How GDB deals with big (>1 Gb) debug files?

From Dev

Uploading huge files (> 2GB) to websphere

From Dev

android: downloadmanager where are the files stored

From Dev

Parsing files over 2.15 GB in Java using Kaitai Struct

From Dev

downloading on DownloadManager and saving file in setDestinationInExternalFilesDir() is not working on Android 10

From Dev

Downloading Large file to certain directory from within app using DownloadManager

From Dev

Print spooler consumes over 1GB of memory

From Dev

Android DownloadManager loading while downloading with api 9

From Dev

file is not downloading via DownloadManager in Android

From Dev

Downloading files from 2 stage authentication protected server

From Dev

Downloading over 1000 files in python

From Dev

Transferring large (8 GB) files over ssh

From Dev

Automatically delete all files in folder that gets over 10GB?

From Dev

Why should I choose BitTorrent over HTTP when downloading large files?

From Dev

Get over 2 GB limit creating PDFs with ImageMagick

From Dev

Downloading free Microsoft VMs with Internet Explorer fails at ~1.5GB-2GB every time

From Dev

"Low Disk Space" after downloading less than 6GB of files on a 128GB Bootable USB

From Dev

Downloading Error With Files over 1.0GB

From Dev

android: downloadmanager where are the files stored

From Dev

NFS lock-up over 1Gb ethernet: Post 14.04.5 to Zyxel NSA325 v2

From Dev

Is 1GB + 1GB RAM better than 2GB +0.5GB?

From Dev

Looping over files with specific column number 1 and number 2

Related Related

  1. 1

    Downloading files >3Gb from S3 fails with "SocketTimeoutException: Read timed out"

  2. 2

    Fiddlercore x-replywithfile over 2gb

  3. 3

    Lotusscript function FileLen returns negative long for files over 2 GB

  4. 4

    Phpseclib sftp put runs out of memory with 1 GB+ files

  5. 5

    file is not downloading via DownloadManager in Android

  6. 6

    Streaming large files (>2GB over IIS) using WebAPI

  7. 7

    downloading files over the internet, if the component has been selected (WITH Inno Tools Downloader)

  8. 8

    How GDB deals with big (>1 Gb) debug files?

  9. 9

    Uploading huge files (> 2GB) to websphere

  10. 10

    android: downloadmanager where are the files stored

  11. 11

    Parsing files over 2.15 GB in Java using Kaitai Struct

  12. 12

    downloading on DownloadManager and saving file in setDestinationInExternalFilesDir() is not working on Android 10

  13. 13

    Downloading Large file to certain directory from within app using DownloadManager

  14. 14

    Print spooler consumes over 1GB of memory

  15. 15

    Android DownloadManager loading while downloading with api 9

  16. 16

    file is not downloading via DownloadManager in Android

  17. 17

    Downloading files from 2 stage authentication protected server

  18. 18

    Downloading over 1000 files in python

  19. 19

    Transferring large (8 GB) files over ssh

  20. 20

    Automatically delete all files in folder that gets over 10GB?

  21. 21

    Why should I choose BitTorrent over HTTP when downloading large files?

  22. 22

    Get over 2 GB limit creating PDFs with ImageMagick

  23. 23

    Downloading free Microsoft VMs with Internet Explorer fails at ~1.5GB-2GB every time

  24. 24

    "Low Disk Space" after downloading less than 6GB of files on a 128GB Bootable USB

  25. 25

    Downloading Error With Files over 1.0GB

  26. 26

    android: downloadmanager where are the files stored

  27. 27

    NFS lock-up over 1Gb ethernet: Post 14.04.5 to Zyxel NSA325 v2

  28. 28

    Is 1GB + 1GB RAM better than 2GB +0.5GB?

  29. 29

    Looping over files with specific column number 1 and number 2

HotTag

Archive