Async ReceiveHTTPFile - File size?

Just starting out? Need help? Post your questions and find answers here.
jacky
User
User
Posts: 63
Joined: Mon Jan 21, 2019 1:41 pm

Async ReceiveHTTPFile - File size?

Post by jacky »

Hi!

I want to download a larger file (100 MB+) from github via

Code: Select all

ReceiveHTTPFile(url, file, #PB_HTTP_Asynchronous)
in a thread and update the progress bar in the main window via

Code: Select all

PostEvent()
Is there a way to get the size of the bytes currently downloaded + the full size of the file to update the progress bar correctly?

I guess I'm too blind today :oops:

Thanks,
jacky
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Async ReceiveHTTPFile - File size?

Post by infratec »

I think you have to do a HTTPRequest() with #PB_HTTP_HeadersOnly first.
Then check the content-length.
jacky
User
User
Posts: 63
Joined: Mon Jan 21, 2019 1:41 pm

Re: Async ReceiveHTTPFile - File size?

Post by jacky »

Thanks infratec!

I've solved the problem getting the correct size of the file to download via HTTPRequest().
A single FindString() isn't enough because the file is stored on Amazon AWS (and not directly on github) and a redirection takes place so the header contains two "Content-Length:" matches.

But I still don't know how to get the current already downloaded size in bytes. Any ideas?

Thanks again,
jacky
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Async ReceiveHTTPFile - File size?

Post by infratec »

HTTPProgress() :?:
Rückgabewert

Der Status des Downloads. Dies kann die aktuelle Anzahl empfangener Bytes sein, oder einer der folgenden Werte:
It returns the already received bytes. (never used it)
jacky
User
User
Posts: 63
Joined: Mon Jan 21, 2019 1:41 pm

Re: Async ReceiveHTTPFile - File size?

Post by jacky »

Args. Shame on me!

Problem solved (it really contains the received bytes)...

Thanks again!
Post Reply