I'm using Delphi 10.3.1 and Indy TIdHTTP / TIdHTTPServer
I created a client / server application to archive files. The client uses a TIdHTTP component, the code is something like this:
procedure TForm1.SendFileClick (Sender: TObject);
var
Stream: TIdMultipartFormDataStream;
begin
Stream: = TIdMultipartFormDataStream.Create;
try
Stream.AddFormField ('field1', 'hello world');
Stream.AddFile ('field2', 'c:\temp\gigafile.mp4');
idHTTP.Post ('http://192.168.1.100:1717', Stream);
finally
Stream.Free;
end;
end;
The server uses a TIdHTTPServer component. Everything seemed to work perfectly until I uploaded very large video files (>= 1GB), because I got the error "Out of memory".
By debugging, I saw that I get the error in function PreparePostStream (line 1229 of the IdCustomHTTPServer unit) when it calls LIOHandler.ReadStream, the event OnCommandGet is not fired yet.
The function LIOHandler.ReadStream goes wrong when it runs AdjustStreamSize (line 2013 of the IdIOHandler unit)
In my last test, with a large video file, in the AdjustStreamSize function, the value of ASize was 1091918544 and I got the error during the execution of
AStream.Size line: = ASize
I think that the origin point of the error is in the System.Classes unit in the following procedure when at the SetPointer ... line.
procedure TMemoryStream.SetCapacity (NewCapacity: NativeInt);
{$ IF SizeOf (LongInt) = SizeOf (NativeInt)}
begin
SetPointer (Realloc (LongInt (NewCapacity)), FSize);
FCapacity: = NewCapacity;
end;
I read many articles on the web but I didn't understand if there is something wrong in my code. How can I solve it or is there a limit to the size of the files I can upload with TIdHTTPServer?
TIdFormDataField
defaults toquoted-printable
only for text fields. It defaults tobinary
for files and streams – Remy Lebeau