Last updated
Was this helpful?
Last updated
Was this helpful?
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, returning null
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 section of this documentation.
A byte array holding the content of the Media object.
Sample
The MIME type of the Media object.
Some examples are: 'image/jpg', 'image/png', etc.
Sample
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.
The name of the Media object.
Sample
Returns the UUID of this media
Sample
Sets the bytes of this media to the give String that is converted to bytes using the UTF-8 Charset.
Parameters
Returns: void
Type A byte array holding the content of the Media object.
Type The MIME type of this Media object.
Returns: This media's bytes as a string converted with the UTF-8 charset, or null if conversion is not possible or bytes are null.
Returns: A String holding the name of this Media object.
Returns: The UUID of this Media object.
string ;
A byte array holding the content of the Media object.
The MIME type of the Media object.
Returns this media's bytes a a String converting it with the UTF-8 Charset.
The name of the Media object.
Returns the UUID of this media
void
Sets the bytes of this media to the give String that is converted to bytes using the UTF-8 Charset.