ballerina.mime package
public struct ContentDisposition
Represent values in Content-Disposition header
Field Name | Data Type | Description | Default Value |
---|---|---|---|
fileName | string | Default filename for storing the bodypart, if the receiving agent wishes to store it in an external file | |
disposition | string | Indicates how the body part should be presented (inline, attachment or as form-data) | |
name | string | Represent the field name in case of 'multipart/form-data' | |
parameters | map | A set of parameters, specified in an attribute=value notation |
public struct Entity
Represent the headers and body of a message. This can be used to represent both the entity of a top level message and an entity(body part) inside of a multipart entity.
Field Name | Data Type | Description | Default Value |
---|---|---|---|
contentType | MediaType | Describes the data contained in the body of the entity | |
contentId | string | Helps one body of an entity to make a reference to another | |
headers | map | Denote general, request/response and entity related headers. Keys of the header map should represent the header name and value will be the 'HeaderValue' struct | |
multipartData | Entity[] | Represent body parts(entities) of a multipart entity | |
size | int | Represent the size of the entity | |
contentDisposition | ContentDisposition | Represent values related to Content-Disposition header |
-
< Entity > getBlob ( ) ( blob )
Given an entity, get the entity body as a blob. If the entity size is considerably large consider using getEntityWrapper() method instead
Return Variable Data Type Description blob Return a blob -
< Entity > getBodyParts ( ) ( Entity[] )
Given an entity, get its body parts.
Return Variable Data Type Description Entity[] Return an array of entities which represent its body parts -
< Entity > getByteChannel ( ) ( ByteChannel )
Given an entity, get the entity body as a byte channel.
Return Variable Data Type Description ByteChannel Return a byte channel -
< Entity > getJson ( ) ( json )
Given an entity, get the entity body in json form.
Return Variable Data Type Description json Return json data -
< Entity > getText ( ) ( string )
Given an entity, get the entity body in text form.
Return Variable Data Type Description string Return text data -
< Entity > getXml ( ) ( xml )
Given an entity, get the entity body in xml form.
Return Variable Data Type Description xml Return xml data -
< Entity > setBlob ( blob blobContent )
Set the entity body with the given blob content
Parameter Name Data Type Description blobContent blob Blob content that needs to be set to entity -
< Entity > setByteChannel ( ByteChannel byteChannel )
Set the entity body with the given byte channel content
Parameter Name Data Type Description byteChannel ByteChannel Byte channel that needs to be set to entity -
< Entity > setFileAsEntityBody ( File fileHandler )
Set the entity body with a given file handler
Parameter Name Data Type Description fileHandler File Represent a file -
< Entity > setJson ( json jsonContent )
Set the entity body with the given json content
Parameter Name Data Type Description jsonContent json Json content that needs to be set to entity -
< Entity > setText ( string textContent )
Set the entity body with the given text content
Parameter Name Data Type Description textContent string Text content that needs to be set to entity -
< Entity > setXml ( xml xmlContent )
Set the entity body with the given xml content
Parameter Name Data Type Description xmlContent xml Xml content that needs to be set to entity
public struct MediaType
Describes the nature of the data in the body of a MIME entity.
Field Name | Data Type | Description | Default Value |
---|---|---|---|
primaryType | string | Declares the general type of data | |
subType | string | A specific format of the primary type data | |
suffix | string | Identify the semantics of a specific media type | |
parameters | map | A set of parameters, specified in an attribute=value notation |
-
< MediaType > toString ( ) ( string )
Get ���primaryType/subtype+suffix��� combination in string format.
Return Variable Data Type Description string Return base type from MediaType struct -
< MediaType > toStringWithParameters ( ) ( string )
Convert the media type to a string suitable for use as the value of a corresponding HTTP header.
Return Variable Data Type Description string Return the Content-Type with parameters as a string
public struct MimeBase64Decoder
Represent MIME specific base64 decoder. This follows RFC 2045 for decoding operation.
-
< MimeBase64Decoder > decode ( blob content ) ( blob )
Decode byte array using MIME Base64 encoding scheme.
Parameter Name Data Type Description content blob the byte array to decode Return Variable Data Type Description blob Return resulting decoded bytes -
< MimeBase64Decoder > decodeString ( string content , string charset ) ( string )
Decode a given string using MIME Base64 decoding scheme. First the given string will be converted to a byte array with the given charset encoding. If the charset given is null default 'UTF-8' will be used. Then that byte array will be decoded using MIME Base64 decoding scheme and a new string will be constructed with the given charset.
Parameter Name Data Type Description content string string to decode charset string charset used in the given string and the resulting string Return Variable Data Type Description string Return resulting decoded string
public struct MimeBase64Encoder
Represent MIME specific base64 encoder. This follows RFC 2045 for encoding operation.
-
< MimeBase64Encoder > encode ( blob content ) ( blob )
Encode byte array using MIME Base64 encoding scheme.
Parameter Name Data Type Description content blob the byte array to encode Return Variable Data Type Description blob Return resulting encoded bytes -
< MimeBase64Encoder > encodeString ( string content , string charset ) ( string )
Encode a given string using MIME Base64 encoding scheme. First the given string will be converted to a byte array with the given charset encoding. If the charset given is null default 'UTF-8' will be used. Then that byte array will be encoded using MIME Base64 encoding scheme and a new string will be constructed with the given charset.
Parameter Name Data Type Description content string string to encode charset string charset used in the given string and the resulting string Return Variable Data Type Description string Return resulting encoded string
public struct QuotedPrintableDecoder
Represent quoated-printable decoder.
public struct QuotedPrintableEncoder
Represent quoated-printable encoder.
public function getMediaType ( string contentType ) ( MediaType )
Given the Content-Type in string, get the MediaType struct populated with it.
Parameter Name | Data Type | Description |
---|---|---|
contentType | string | Content-Type in string |
Return Variable | Data Type | Description |
---|---|---|
MediaType | Return MediaType struct |
APPLICATION_FORM_URLENCODED
Attribute Name | Data Type | Description |
---|---|---|
APPLICATION_FORM_URLENCODED | string | Represent 'application/x-www-form-urlencoded' media type value |
APPLICATION_JSON
Attribute Name | Data Type | Description |
---|---|---|
APPLICATION_JSON | string | Represent 'application/json' media type value |
APPLICATION_OCTET_STREAM
Attribute Name | Data Type | Description |
---|---|---|
APPLICATION_OCTET_STREAM | string | Represent 'application/octet-stream' media type value |
APPLICATION_SVG_XML
Attribute Name | Data Type | Description |
---|---|---|
APPLICATION_SVG_XML | string | Represent 'application/svg+xml' media type value |
APPLICATION_XHTML_XML
Attribute Name | Data Type | Description |
---|---|---|
APPLICATION_XHTML_XML | string | Represent 'application/xhtml+xml' media type value |
APPLICATION_XML
Attribute Name | Data Type | Description |
---|---|---|
APPLICATION_XML | string | Represent 'application/xml' media type value |
MULTIPART_FORM_DATA
Attribute Name | Data Type | Description |
---|---|---|
MULTIPART_FORM_DATA | string | Represent 'multipart/form-data' media type value |
MULTIPART_MIXED
Attribute Name | Data Type | Description |
---|---|---|
MULTIPART_MIXED | string | Represent 'multipart/mixed' media type value |
TEXT_HTML
Attribute Name | Data Type | Description |
---|---|---|
TEXT_HTML | string | Represent 'text/html' media type value |
TEXT_PLAIN
Attribute Name | Data Type | Description |
---|---|---|
TEXT_PLAIN | string | Represent 'text/plain' media type value |
TEXT_XML
Attribute Name | Data Type | Description |
---|---|---|
TEXT_XML | string | Represent 'text/xml' media type value |
BOUNDARY
Attribute Name | Data Type | Description |
---|---|---|
BOUNDARY | string | Key name for 'boundary' parameter in MediaType. This is needed for composite type media types |
START
Attribute Name | Data Type | Description |
---|---|---|
START | string | Key name for 'start' parameter in MediaType. This determines which part in the multipart message contains the payload |
TYPE
Attribute Name | Data Type | Description |
---|---|---|
TYPE | string | Key name for 'type' parameter in MediaType. This indicates the MIME media type of the 'root' body part |
CHARSET
Attribute Name | Data Type | Description |
---|---|---|
CHARSET | string | Key name for 'charset' parameter in MediaType. Indicate the character set of the body text |
DEFAULT_CHARSET
Attribute Name | Data Type | Description |
---|---|---|
DEFAULT_CHARSET | string | Default charset to be used with MIME encoding and decoding |