function TForm3.SendFileViaHTTPS(aFile:
String):
String;
var aResponceStream: TMemoryStream;
aFileName:
string;
begin
aFileName := ExtractFileName(aFile);
IdHTTP1.Request.BasicAuthentication := True;
IdHTTP1.Request.Username := '
Username';
IdHTTP1.Request.Password := '
Password';
aResponceStream := TMemoryStream.Create();
aResponceStream.Clear;
aResponceStream.Seek(0,soFromBeginning);
try
try
IdHTTP1.Post(Format('
https://services.irgendwas.de/upload-api/upload/%s',[aFileName]), aFile, aResponceStream);
aResponceStream.Seek(0,soFromBeginning);
Memo1.Lines.LoadFromStream(aResponceStream);
Memo1.Lines.Add(IdHTTP1.ResponseCode.ToString);
except
on E: EIdHTTPProtocolException
do
begin
aResponceStream.Seek(0,soFromBeginning);
Memo1.Lines.LoadFromStream(aResponceStream);
Memo1.Lines.Add(IdHTTP1.ResponseCode.ToString);
end;
end;
finally
aResponceStream.Free;
end;
end;