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);
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 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 A String holding the name of this Media object.
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);