JSMedia
Overview
JSMedia
is a media wrapper designed for managing media content within solutions. It enables manipulation of media properties such as content bytes, MIME types, and metadata through a set of defined properties and methods.
The bytes
property represents the content of the media as a byte array. This allows direct modification of the media content while retaining its original name. For example, users can read image files, replace their content, and verify changes programmatically. The mimeType
property specifies the type of media, such as 'image/jpg' or 'image/png'. It can be updated alongside the content to reflect new media formats without altering the media’s name.
JSMedia provides several methods for interacting with media objects:
getAsString()
: Converts the byte content into a UTF-8 encoded string, returningnull
if the conversion fails or if the byte content is unavailable.getName()
: Retrieves the name of the media object, ensuring that changes to content or MIME type do not affect the original name.getUUID()
: Returns a unique identifier (UUID) for the media, allowing for precise identification.setAsString(string)
: Updates the media’s byte content using a UTF-8 encoded string, enabling quick modifications with string inputs.
For more comprehensive information, refer to the media section of this documentation.
Properties Summarized
Methods Summarized
void
Sets the bytes of this media to the give String that is converted to bytes using the UTF-8 Charset.
Properties Detailed
bytes
A byte array holding the content of the Media object.
Type Array
Sample
mimeType
The MIME type of the Media object.
Some examples are: 'image/jpg', 'image/png', etc.
Type String
Sample
Methods Detailed
getAsString()
Returns this media's bytes a a String converting it with the UTF-8 Charset. Returns null if it couldn't convert it or the bytes where null.
Returns: String
getName()
The name of the Media object.
Returns: String A String holding the name of this Media object.
Sample
getUUID()
Returns the UUID of this media
Returns: UUID
Sample
setAsString(string)
Sets the bytes of this media to the give String that is converted to bytes using the UTF-8 Charset.
Parameters
String string ;
Returns: void
Last updated