Idhttp grab file size downloaded

Asked

Viewed 372 times

3

Well, I would like to know how to find the file size that is being downloaded with the Idhttp component.

1 answer

4


You must request the HEAD operation with the file address

var
  HttpClient: TIdHttp;
  FileSize: Int64;
begin
  HttpClient := TIdHttp.Create(nil);
  try
    HttpClient.Head('http://somewhere.com/somefile.exe');
    FileSize := HttpClient.Response.ContentLength;
  finally
    HttpClient.Free;
  end;
end;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.