Extraer fichero de un formulario / API multipart con ReadMIMEMessage
Hola! Comparto hoy un ejemplo de Yuri Marx sobre el uso de ReadMIMEPart
. Si necesitáis obtener un fichero de una API o formulario multipart echadle un ojo a este ejemplo:
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
}
}