Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TFileStream and IdHTTP in indy10

Status
Not open for further replies.

Jimmy303

IS-IT--Management
Mar 15, 2007
2
US
I have been looking around and found no help with this.

I am using a TFileStream with the indy TIdHTTP for a simple downloader. I have got everything working correctly with one exception. When using the call

IdHTTP.Get(DownloadSource, FileStream);

As soon as it starts downloading TIdHTTP pre-sets the filesize of the downloading file to the full size of the complete file. When the connection is closed gracefully the filesize is set to the correct amount of downloaded data to that point. I can then continue the download at another time. However the problem is if the application crashes or is terminated the file size is left at the incorrectly full size which I cannot detect to continue and restart the download, it now is just a corrupt file.

Any help or suggestions would be greatly appreciated,

Jimmy303
 
Hi Jimmy,;

I have had the very same issue. the solution is simple : use a TMemorystream in between.

so something like that (pseudo code):

IdHTTP.Get(DownloadSource, MemoryStream);
// when finished, crashed or whatever:
MemoryStream.SaveToFile(FileStream);

keep in mind that when downloading *large* files this may be not a good option...



-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
whosrdaddy,

Thank you for your help. I actually am using large files 300MB + but this gets my brain out of the box it's been stuck in for this project. I am going to try some code and post the result if it works.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top