Question
· Feb 20, 2018

REST Data Limit

I'm experimenting with sending large amounts of data in a POST payload to be stored as a stream. However I've noticed that no matter how many characters are in the message, Cache only gets about 32k of them, cutting off the rest. Conversely as expected it can only send about 32k worth of characters in a payload.

Before I get creative, is there a REST message size limit that can be changed? Or is there something else going on here?

Thank you!

Discussion (9)0
Log in or sign up to continue

Well, in this case you definitely don't need to read from stream at all. You can save the stream in the database (or file using %Stream.FileCharacter)) and send it to the client later:

set stream = ##class(%Stream.GlobalCharacter).%New()
set sc = stream.CopyFromAndSave(%request.Content)
set oid = stream.%Oid()
kill (oid)
set stream = ##class(%Stream.GlobalCharacter).%Open(oid)
do stream.OutputToDevice()

Streams can be class properties too.

What you've shown me inspired me to try something else...I can't draw from %request.Content.Data directly because it's always undefined, so I've had to use Read() all of the time whenever I need Data values from POST messages.

This seems to be working for any size so far, and I think I can come up with something more efficient later, but at least it's working!

set stream = ##class(%Stream.GlobalCharacter).%New()
While (%request.Content.AtEnd = 0) {
     Set len = $$$MaxStringLength
     do stream.Write(%request.Content.Read(.len))

}

//etc..


Set outputStream = ##class(%Stream.GlobalCharacter).%Open(oid)
While (outputStream .AtEnd = 0) {
     Set len = $$$MaxStringLength
     Write outputStream .Read(.len)
 }