By Admin on Tuesday, 13 April 2021
Category: All

HTTP Post Big Files

​sgcWebSockets Servers allow to Post Big Files without affecting the server memory. 

When a HTTP client sends a multipart/form-data stream, the stream is saved by server in memory. When the files are big, the server can get an out of memory exception, to avoid these exceptions, the server has a property called HTTPUploadFiles where you can configure how the POST streams are handled: in memory or as a file streams. If the streams are handled as file streams, the streams received are stored directly in the hard disk so the memory problems are avoided.

Server Configuration 

To configure your server to save multipart/form-data streams as file streams, follow the next steps:

1. Set the property HTTPUploadFiles.StreamType = pstFileStream. Using this setup, the server will store these streams in the hard disk.

2. You can configure which is the minimum size in bytes where the files will be stored as file stream. By default the value is zero, which means all streams will be stored as file stream.

3. The folder where the streams are stored using SaveDirectory, if not set, will be stored in the same folder where the application is.

4. When a client sends a multipart/form-data, the content is encoded inside boundaries, if the property RemoveBoundaries is enabled, the content of boundaries will be extracted automatically after the full stream is received. 

Sample Code

Related Posts