You are not logged in.
Pages: 1
Hi,
I'm generating big files on server side and need to download them to client.
On server side:
Ctxt.ReturnFile(FileName, false, 'application/octet-stream');
On client side:
if FClient.CallBackGet('GetFile', ['FileName', aFileName], FileContent) <> HTTP_SUCCESS then
raise Exception.CreateFmt('Cannot get result file from server: %s', [FileContent]);
FileFromString(FileContent, 'somefile.big', true);
It works ok, but my concern is the memory consumption when files are 1GB+ in size.
How can I save the downloaded content to a stream "on the fly" and not having the file's content all at once in the RAM (in FileContent variable)?
Offline
On mORMot 1, the usual way is to use a reverse proxy then let it return static files.
There are nginx-related methods when you setup the HTTP server.
For mORMot 2, the new async HTTP Server is able to stream the file directly (when files are > 1MB).
But the best way on production may be still to define a nginx reverse proxy.
Offline
Hi ab,
To use the new async features with TRestHttpServer just use useHttpAsync option?
Offline
Thanks ab,
I was initially searching for an TRestHttpAsyncServer , but it's even simpler than that.
Offline
Hi ab
Streaming the file directly from the server is great. I wish this was possible with mORMot 1. If I may get back to the second half of dexter's question - saving of the file by the client. Is there a way for the client (ie TWinHTTP.Request) to stream the bytes received from the server directly to file/disk without caching it in memory first?
Offline
Not directly in the REST/SOA interface.
But the new WGet() methods are meant for such complex client process, including a lot of additional features like progress callbacks, hashing and even resuming!
For a huge content downloading, it makes sense to use a dedicated call with its own connection, perhaps in a background thread.
Offline
Pages: 1