1

I can't seem to be able to get DownloadManager in Java/Android properly decode gzip files (in this case from S3 bucket). Same link decodes properly when downloading from, say, Chrome, which seems to use DownloadManager as well. There doesn't seem to be anything in the docs that explain how to do this.

here's some sample code. The result is the file gets downloaded, but is still in gzipped format. Not the case when downloading with chrome. How do I do this properly?

downmanager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); 
Request request = new Request(Uri.parse("https://somurl.com/somefile.wad"));
request.addRequestHeader("Accept-Encoding", "gzip, deflate");

Uri localUri = Uri.parse("file://"+this.getExternalFilesDir(null).getPath()+"/test.wad");
request.setDestinationUri(localUri);

downmanager.enqueue(request); 
Scritch
  • 31
  • 3
  • Possible duplicate: http://stackoverflow.com/questions/10469407/android-decompress-downloaded-xml-gz-file – T D Nguyen Mar 03 '16 at 02:26
  • So you're expecting the download manager to decompress the file response just because you put an Accept-Encoding in the request? – Doug Stevenson Mar 03 '16 at 05:04
  • not the same as other link, since I want to leverage Android's DownloadService for a variety of reasons, such as download resume, downloading outside of app, etc. – Scritch Mar 03 '16 at 05:11
  • Yes, expecting the downloadmanager to decompress the resulting file on the fly, in the same way that browsers auto decode on download of the same file. it is tagged with content-encoding: gzip in S3 as well. The same flow on iOS with iOS's built in download methods produces the desired result, as another example. Also interestingly, Chrome on Android, which appears to also use DownloadManager, does this correctly as well, leading me to believe it should work, and I'm missing something. – Scritch Mar 03 '16 at 05:12
  • Anybody have any ideas? i still can't figure out what chrome is doing differently than me. – Scritch Mar 13 '16 at 03:01

0 Answers0