This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Functions - mime

base64Decode

Deprecated API.

base64DecodeBlob

Deprecated API.

base64Encode

Deprecated API.

base64EncodeBlob

Deprecated API.

getContentDispositionObject

Given the Content-Disposition as a string, gets the ContentDisposition object with it.

getMediaType

Gets the MediaType object populated with it when the Content-Type is in string.

prepareDecodingErrorWithDetail

Constructs a DecodeError with the given details.

prepareEncodingErrorWithDetail

Constructs an EncodeError with the given details.

base64Decode

(string | byte[] | ReadableByteChannel contentToBeDecoded, string charset)

returns string | byte[] | ReadableByteChannel | DecodeError

Deprecated API. Decodes a given input with MIME specific Base64 encoding scheme.

Parameters

  • contentToBeDecoded string | byte[] | ReadableByteChannel
  • Content that needs to be decoded can be of type string, byte[] or io:ReadableByteChannel

  • charset string (default utf-8)
  • Charset to be used. This is used only with the string input

  • Return Type

    (string | byte[] | ReadableByteChannel | DecodeError)
  • A decoded string if the given input is of type string, a decoded byte[] if the given input is of type byte[], a decoded io:ReadableByteChannel if the given input is of type io:ReadableByteChannel or else a mime:DecodeError in case of errors

base64DecodeBlob

(byte[] valueToBeDecoded)

returns byte[] | DecodeError

Deprecated API. Decodes a given byte[] using the Base64 encoding scheme.

Parameters

  • valueToBeDecoded byte[]
  • Content, which needs to be decoded

  • Return Type

    (byte[] | DecodeError)
  • A decoded byte[] or else a mime:DecodeError record in case of errors

base64Encode

(string | byte[] | ReadableByteChannel contentToBeEncoded, string charset)

returns string | byte[] | ReadableByteChannel | EncodeError

Deprecated API. Encodes a given input with MIME specific Base64 encoding scheme.

Parameters

  • contentToBeEncoded string | byte[] | ReadableByteChannel
  • Content that needs to be encoded can be of type string, byte[] or io:ReadableByteChannel

  • charset string (default utf-8)
  • Charset to be used. This is used only with the string input

  • Return Type

    (string | byte[] | ReadableByteChannel | EncodeError)
  • An encoded string if the given input is of type string, an encoded byte[] if the given input is of type byte[], an encoded io:ReadableByteChannel if the given input is of type io:ReadableByteChannel, or else a mime:EncodeError record in case of errors

base64EncodeBlob

(byte[] valueToBeEncoded)

returns byte[] | EncodeError

Deprecated API. Encodes a given byte[] using the Base64 encoding scheme.

Parameters

  • valueToBeEncoded byte[]
  • Content, which needs to be encoded

  • Return Type

    (byte[] | EncodeError)
  • An encoded byte[] or else a mime:EncodeError record in case of errors

getContentDispositionObject

(string contentDisposition)

returns ContentDisposition

Given the Content-Disposition as a string, gets the ContentDisposition object with it.

Parameters

  • contentDisposition string
  • Content disposition string

getMediaType

(string contentType)

returns MediaType | InvalidContentTypeError

Gets the MediaType object populated with it when the Content-Type is in string.

Parameters

  • contentType string
  • Content-Type in string

prepareDecodingErrorWithDetail

(string detail)

returns DecodeError

Constructs a DecodeError with the given details.

Parameters

  • detail string
  • Error details

  • Return Type

    (DecodeError)
  • DecodeError with the given details set to the message

prepareEncodingErrorWithDetail

(string detail)

returns EncodeError

Constructs an EncodeError with the given details.

Parameters

  • detail string
  • Error details

  • Return Type

    (EncodeError)
  • An EncodeError with the given details set to the message