Note that there are some explanatory texts on larger screens.

plurals
  1. POGet size of uncompressed gzip file while size of compressed file is available from server
    text
    copied!<p>I am using <code>GZIPInputStream</code> to download PDF file. I want to show the download progress of the file on a UI button. But, I am not getting the actual size of the file, what I am getting is compressed size due to which I am unable to show the correct download progress. This download progress is exceeding <code>100</code> as the actual file size is greater than the compressed size of file.</p> <p>Header content of file from server: Following info I receive from server, from which I am using <code>content-length</code> which is giving compressed file size.</p> <pre><code>1.Connection 2.Content-Encoding 3.Content-length 4.Content-Type 5.Keep-Alive 6.Server 7.Date </code></pre> <p>Here is my code. Is there any way to get original size of file?</p> <pre><code>long fileLength = httpResponse.getEntity().getContentLength();// GZIPInputStream input = new GZIPInputStream(new BufferedInputStream( httpResponse.getEntity().getContent())); FileOutputStream output = new FileOutputStream(destinationFilePath); byte data[] = new byte[1024]; long total = 0; float percentage = 0; int count; currentDownloadingPercentage=0; while ((count = input.read(data)) != -1) { total += count; output.write(data, 0, count); // publishing the progress.... percentage = (float)total/(float)fileLength; percentage *= 100; if ((int)percentage &gt; (int)currentDownloadingPercentage) { currentDownloadingPercentage = percentage; Bundle resultData = new Bundle(); resultData.putBoolean(DOWNLOAD_FAILED, false); resultData.putInt(DOWNLOAD_PROGRESS ,(int)percentage); receiver.send(processID, resultData); resultData = null; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload