We are using TMS Web Core 2.7.2 and the Edge browser (v134).
If we download a file of 684 bytes from a memory stream by the call
Application.DownloadBinaryFile(TMemoryStream.MemoryToBytes(TMemoryStream(lxStream).Memory), ltFileName, True)
the downloaded file is 4096 bytes in size, where every byte after the 684 bytes is a null byte.
Is there a way to download the file so that the file size is kept?
This issue comes from the pas2js RTL TMemoryStream implementation that allocates memory in chunks of 4096 bytes.
The reason for this choice is to avoid having to allocate memory too frequently while filliing this memory stream.
What you could do is resize the TJSArrayBuffer returned by MemoryToBytes() to the actual size in bytes via the TJSArrayBuffer.resize() call before saving this stream to a file.
1 Like