Extract a file from a multipart form or api using ReadMIMEMessage
If you want get a file from a multipart API or html form request use ReadMIMEMessage, see my sample.
Class dc.Test.TestService Extends Ens.BusinessService
{
Parameter ADAPTER = "EnsLib.HTTP.InboundAdapter";
Method OnProcessInput(pInput As %GlobalBinaryStream, pOutput As %RegisteredObject) As %Status
{
Set file=##class(%Stream.FileBinary).%New()
Set file.Filename="/tmp/automl11.png"
Set reader = ##class(%Net.MIMEReader).%New()
//Set message = ##class(%Net.MIMEPart).%New()
Do reader.OpenStream(pInput)
Set tsc2 = reader.ReadMIMEMessage(.message)
Do message.ClearHeaders()
Do file.CopyFromAndSave(message.Body)
Set tSC=$$$OK
Set pOutput = "success"
Quit tSC
}
}