use of org.ballerinalang.mime.util.EntityBodyChannel in project ballerina by ballerina-lang.
the class Util method getXmlBodyPart.
/**
* Get a xml body part from a given xml content.
*
* @param result Result of ballerina file compilation
* @return A ballerina struct that represent a body part
*/
static BStruct getXmlBodyPart(CompileResult result) {
BXMLItem xmlContent = new BXMLItem("<name>Ballerina</name>");
BStruct bodyPart = getEntityStruct(result);
EntityBodyChannel byteChannel = new EntityBodyChannel(new ByteArrayInputStream(xmlContent.getMessageAsString().getBytes(StandardCharsets.UTF_8)));
bodyPart.addNativeData(ENTITY_BYTE_CHANNEL, new EntityWrapper(byteChannel));
MimeUtil.setContentType(getMediaTypeStruct(result), bodyPart, APPLICATION_XML);
return bodyPart;
}
Aggregations