question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get file size prior to start downloading it

See original GitHub issue

I’ve started using the library and gone through the simple implementation, although it doesn’t tell about implementation of getting size of file before actually downloading it.

What i tried so far is

String downloadLink = VALID_FILE_URL;
String filePath = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_DOWNLOADS + File.separator + "file.mp4";
Logger.log(String.valueOf(FileDownloader.getImpl().create(downloadLink).setPath(filePath).getSmallFileTotalBytes()));

but it’s returning 0.00 every time i execute the above code.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19

github_iconTop GitHub Comments

1reaction
Jacksgongcommented, Aug 2, 2016

OK. I think I know, now. If you want to get TotalBytes through FileDownloader instead of standalone API.

Though I don’t recommend, but you can get totalBytes in FileDownloadListener#connected, it is better than in FileDownloadListener#progress which you did.

1reaction
Jacksgongcommented, Jul 31, 2016

can’t use FileDownloader.getImpl().create(downloadLink).setPath(filePath).getSmallFileTotalBytes() to get so far bytes of a running task.

You can get so far bytes of a running task by fellow ways:

  1. in methods of FileDownloadListener which attached to the task object.
  2. use FileDownloader#getSoFar through the task Id.
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to know the size of a file before downloading it?
you can get a header called Content-Length form the HTTP Response object that you get, this will give you the length of the...
Read more >
How to display file size before starting a download?
To know the file size of a download where the size is not returned by the webserver, you will have to attempt downloading...
Read more >
Tip – How to check file size before download from URL
Click on the link to download. Configure SSIS REST API Task to Get file size from URL. Now lets look at how to...
Read more >
How to get the file size before downloading ? : r/tasker - Reddit
All I need is to get the file size and store it in variable ... But now how do I check when the...
Read more >
Chapter 9 Uploads and downloads - Mastering Shiny
By default, the user can only upload files up to 5 MB. You can increase this limit by setting the shiny.maxRequestSize option prior...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found