Functions - mime

base64Decode

Decodes a given input with MIME specific Base64 encoding scheme.

base64DecodeBlob

Decodes a given byte[] with Base64 encoding scheme.

base64Encode

Encodes a given input with MIME specific Base64 encoding scheme.

base64EncodeBlob

Encodes a given byte[] with Base64 encoding scheme.

getContentDispositionObject

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

getMediaType

Given the Content-Type in string, gets the MediaType object populated with it.

prepareDecodingErrorWithDetail
prepareEncodingErrorWithDetail

base64Decode

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

returns string | byte[] | ReadableByteChannel | DecodeError

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 - utf-8
  • Charset to be used. This is used only with the string input

  • Return Type

    (string | byte[] | ReadableByteChannel | DecodeError)
  • If the given input is of type string, a decoded string is returned. If the given input is of type byte[], a decoded byte[] is returned. If the given input is of type io:ReadableByteChannel, a decoded io:ReadableByteChannel is returned. In case of errors, an DecodeError record is returned.

base64DecodeBlob

(byte[] valueToBeDecoded)

returns byte[] | DecodeError

Decodes a given byte[] with Base64 encoding scheme.

Parameters

  • valueToBeDecoded byte[]
  • Content that needs to be decoded

  • Return Type

    (byte[] | DecodeError)
  • A decoded byte[]. In case of errors, an DecodeError record is returned

base64Encode

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

returns string | byte[] | ReadableByteChannel | EncodeError

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 - utf-8
  • Charset to be used. This is used only with the string input

  • Return Type

    (string | byte[] | ReadableByteChannel | EncodeError)
  • If the given input is of type string, an encoded string is returned. If the given input is of type byte[], an encoded byte[] is returned. If the given input is of type io:ReadableByteChannel, an encoded io:ReadableByteChannel is returned. In case of errors, an EncodeError record is returned.

base64EncodeBlob

(byte[] valueToBeEncoded)

returns byte[] | EncodeError

Encodes a given byte[] with Base64 encoding scheme.

Parameters

  • valueToBeEncoded byte[]
  • Content that needs to be encoded

  • Return Type

    (byte[] | EncodeError)
  • An encoded byte[]. In case of errors, an EncodeError record is returned

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

Given the Content-Type in string, gets the MediaType object populated with it.

Parameters

  • contentType string
  • Content-Type in string

prepareDecodingErrorWithDetail

(string detail)

returns DecodeError

Parameters

prepareEncodingErrorWithDetail

(string detail)

returns EncodeError

Parameters