Child pages
  • JSMedia
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 31 Current »

Refresh page Apr 29, 2024 10:22

Supported Clients
SmartClient WebClient NGClient

Property Summary
Array bytes A byte array holding the content of the Media object.
String mimeType The MIME type of the Media object.

Methods Summary
String getAsString() Returns this media's bytes a a String converting it with the UTF-8 Charset.
String getName() The name of the Media object.
UUID getUUID() Returns the UUID of this media
void setAsString(string) Sets the bytes of this media to the give String that is converted to bytes using the UTF-8 Charset.

Property Details

bytes

A byte array holding the content of the Media object.

Returns

Supported Clients

SmartClient,WebClient,NGClient

Sample

var ballBytes = plugins.file.readFile('d:/ball.jpg');
var mapBytes = plugins.file.readFile('d:/map.png');
var ballImage = solutionModel.newMedia('ball.jpg', ballBytes);
application.output('original image name: ' + ballImage.getName());
ballImage.bytes = mapBytes;
ballImage.mimeType = 'image/png';
application.output('image name after change: ' + ballImage.getName()); // The name remains unchanged. Only the content (bytes) are changed.
application.output('image mime type: ' + ballImage.mimeType);
application.output('image size: ' + ballImage.bytes.length);

mimeType

The MIME type of the Media object.

Some examples are: 'image/jpg', 'image/png', etc.

Returns

Supported Clients

SmartClient,WebClient,NGClient

Sample

var ballBytes = plugins.file.readFile('d:/ball.jpg');
var mapBytes = plugins.file.readFile('d:/map.png');
var ballImage = solutionModel.newMedia('ball.jpg', ballBytes);
application.output('original image name: ' + ballImage.getName());
ballImage.bytes = mapBytes;
ballImage.mimeType = 'image/png';
application.output('image name after change: ' + ballImage.getName()); // The name remains unchanged. Only the content (bytes) are changed.
application.output('image mime type: ' + ballImage.mimeType);
application.output('image size: ' + ballImage.bytes.length);

Methods Details

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

Supported Clients

SmartClient,WebClient,NGClient

Sample

 

getName()

The name of the Media object.

Returns

Supported Clients

SmartClient,WebClient,NGClient

Sample

var ballBytes = plugins.file.readFile('d:/ball.jpg');
var mapBytes = plugins.file.readFile('d:/map.png');
var ballImage = solutionModel.newMedia('ball.jpg', ballBytes);
application.output('original image name: ' + ballImage.getName());
ballImage.bytes = mapBytes;
ballImage.mimeType = 'image/png';
application.output('image name after change: ' + ballImage.getName()); // The name remains unchanged. Only the content (bytes) are changed.
application.output('image mime type: ' + ballImage.mimeType);
application.output('image size: ' + ballImage.bytes.length);

getUUID()

Returns the UUID of this media

Returns

Supported Clients

SmartClient,WebClient,NGClient

Sample

var ballImg = plugins.file.readFile('d:/ball.jpg');
application.output(ballImg.getUUID().toString());

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 ;

Supported Clients

SmartClient,WebClient,NGClient

Sample

 

  • No labels