[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Finding the size of a file prior to download



Mike,

Thanks for the quick response.

I have gone through all of your suggestions already prior to leaning on the
httpapi community.
My program needs to do this in real time so don't want to go down the ftp
route. It's programmatical so can't 'see' the remote folder prior to
download. 
My downloads are in real time so its mainly just to give the user some idea
if the download may take some time. It has no effect on the actual download.
But thanks.

Looking at the Windows API (WinInet) - (similar to httpapi) -  they suggest
using the http protocol 'HEAD' (instead of 'GET') but have no idea where
that fits in.

At the end of the day it?s a 'nice to have' but won't affect the
functionality of the system.

Thanks again
Regards
 
Ian Patterson
 
-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Mike Krebs
Sent: 15 September 2014 19:43
To: HTTPAPI and FTPAPI Projects
Subject: RE: Finding the size of a file prior to download

You already figured out the problem...
If it is not chunked, you can parse the header for the file size. If it is
chunked the file size is determined on the fly.

So, an idea or two. Is the file sitting somewhere that you can see? Maybe
you can FTP or even http browse the directory and see the files and their
sizes? Obviously this would mean that the server would need that directory
in the ftp server config or for http would need some files to NOT be present
and some directives to be turned on. For Apache, see this page for that:

https://wiki.apache.org/httpd/DirectoryListings

If the file is being built on the fly, there just is not a good solution
except to turn off chunking. 

I don't recall and don't have time to look it up but maybe you can "lie" to
the server and tell it you are using http 1.0 and see if it will buffer the
file for you. Then you could get the size in the header at the start of the
download.


-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Ian Patterson
Sent: Monday, September 15, 2014 1:21 PM
To: 'HTTPAPI and FTPAPI Projects'
Subject: Finding the size of a file prior to download

We use httpapi to download files (binary and SSL).
It would be useful to know what the file size is prior to downloading it.

We use GET with and without chunking but can't see a method to establish the
download file size before the download.
Especially with chunked downloads where the content length is the chunk.

Any ideas anyone?

 
Regards
 
Ian Patterson
 

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------