PeterO.Mail.DataUris

## PeterO.Mail.DataUris

public static class DataUris

Contains methods for parsing and generating Data URIs (uniform resource identifiers). Data URIs are described in RFC 2397. Examples for Data URIs follow.

data:, hello%20world

data:text/markdown, hello%20world

data:application/octet-stream;base64, AAAAAA==

.

Member Summary

### DataUriBytes

public static byte[] DataUriBytes(
    string uri);

Extracts the data from a Data URI (uniform resource identifier) in the form of a byte array.

Parameters:

Return Value:

The data as a byte array. Returns null if uri is null, is syntactically invalid, or is not a data URI.

Exceptions:

### DataUriBytes

public static byte[] DataUriBytes(
    System.Uri uri);

Extracts the data from a Data URI (uniform resource identifier) in the form of a byte array, where the Data URI is given as a URI object.

Parameters:

Return Value:

The data as a byte array. Returns null if uri is null, is syntactically invalid, or is not a data URI.

Exceptions:

### DataUriMediaType

public static PeterO.Mail.MediaType DataUriMediaType(
    string uri);

Extracts the media type from a Data URI (uniform resource identifier) in the form of a text string.

Parameters:

Return Value:

The media type. Returns null if uri is null, is syntactically invalid, or is not a Data URI.

Exceptions:

### DataUriMediaType

public static PeterO.Mail.MediaType DataUriMediaType(
    System.Uri uri);

Extracts the media type from a Data URI (uniform resource identifier) in the form of a URI object.

Parameters:

Return Value:

The media type. Returns null if uri is null, is syntactically invalid, or is not a Data URI.

Exceptions:

### MakeDataUri

public static string MakeDataUri(
    byte[] bytes,
    PeterO.Mail.MediaType mediaType);

Encodes data with the given media type in a Data URI (uniform resource identifier).

Parameters:

Return Value:

A Data URI that encodes the given data and media type.

Exceptions:

### MakeDataUri

public static string MakeDataUri(
    string textString);

Encodes text as a Data URI (uniform resource identifier).

Parameters:

Return Value:

A Data URI that encodes the given text.

Exceptions:

Back to MailLib start page.