Function call in Download a object #20
Closed
DevintTechnology
started this conversation in
Ideas
Replies: 1 comment
-
|
You can now implement uses {...}, AWS.Configs, System.Net.HttpClient;
type
TMyHttpClientFactory = class(TInterfacedObject, IHttpClientFactory)
strict private
FCallback: TProgressProc;
public
function CreateHttpClient(Config: TValue): TValue;
constructor Create(ACallback: TProgressProc);
end;
constructor TMyHttpClientFactory.Create(ACallback: TProgressProc);
begin
inherited Create;
FCallback := ACallback;
end;
function TMyHttpClientFactory.CreateHttpClient(Config: TValue): TValue;
begin
var Client := THttpClient.Create;
if Assigned(FCallback) then
Client.ReceiveDataCallback :=
procedure(const Sender: TObject; AContentLength, AReadCount: Int64; var AAbort: Boolean)
begin
FCallback(AReadCount, AContentLength);
end;
Result := Client;
end;
{...}
procedure TForm4.DownloadSomeBigFile;
begin
var Config := TAmazonS3Config.Create;
var Client := TAmazonS3Client.Create(Config);
Config.HttpClientFactory := TMyHttpClientFactory.Create(
procedure(const BytesRead, Total: Int64)
begin
Memo2.Lines.Add(Format('%d of %d bytes read (%2.f %%)', [BytesRead, Total, BytesRead / Total * 100]));
Application.ProcessMessages;
end
);
var response := Client.GetObject('mybucket', 'bigfile.dat');
end; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It would be very interesting to be able to put a function in GetObject to call up the percentage of completion and display it.
Beta Was this translation helpful? Give feedback.
All reactions