Sign in to follow this  
Eldritch

Size of remote file

Recommended Posts

Hi! I am trying to acquire the size of a remote file (accessed via a URL) so I can print that to the user in my download prompt. I checked GetFileSizeEx(), but that seems to be only for local files.

Share this post


Link to post
Share on other sites
What language and API? How are you downloading the file? If it's via a URL, there isn't necessarily any guarantee the server will tell you the size, it may just keep sending bytes and then close the connection when it's transferred.

Share this post


Link to post
Share on other sites
The web server may send its size in an accompanying header (content-length). However, like Steve pointed out, there are no guarantees that the information is correct or at all present.

Share this post


Link to post
Share on other sites
Quote:
Original post by Eldritch
Sorry, I am using WINAPI and C/C++. How would I do to access this header?
What functions are you using for the network side? WinSock? There's no magical GetFileFromRemoteServer() function that I know of.

The header is sent as part of the HTTP request, which you'll have to parse if you're doing the network code yourself.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this