AGK for Pascal
TAgkHttpConnection.GetFileASync Method (TAgkHttpCompletionEvent, String, String, String)

Downloads an HTTP file from the server connected to using Connect and saves it to the location specified. Fires a notification event when the download has completed.

procedure GetFileASync(const OnCompletion: TAgkHttpCompletionEvent; const ServerFile: String; const LocalFile: String; const PostData: String = ''); overload;
const OnCompletion: TAgkHttpCompletionEvent 
The event that is fired when the download has completed. 
const ServerFile: String 
The file to request from the server, include everything after the domain part of the URL. 
const LocalFile: String 
The location to save to file. This will be inside the write folder for the current device. 
const PostData: String = '' 
(optional) The raw post data to send to the server. Note that & and = are special characters that separate variables. 

Also allows you to send POST data to the server which can include variables or file data, e.g. 'myvar=5&var2=test'. This method returns immediately and continues the file download in the background. 

When the OnCompletion event fires, the download has completed and the file will then be at the location you specified ready for use with AGK. The Connection parameter of the event will be this connection. 

You can also check the download progress using FileProgress

There is also a version of GetFileASync that does not use an event, but requires you to poll for completion instead.

Copyright (c) 2012. All rights reserved.