Xibo 2.0.0 API Add a image to a Layout

I would like to know if there is a way to a image to a Layout through the api. If so, could you exemplify?

you can replace a media file in the library through the API.
Library add -request uploads a file to the CMS. This API call also makes it possible to replace
a file in the library. You can also specify if you wish to update the file in layouts.

  1. Create layout and assinge a image from the library to it.
  2. Get the mediaId of the file (left most value in the media library for the image).
  3. Send new file with API call, if the request is succesful save the new mediaId for use
    in the next request.

If you want to make the changes in the layouts as quick as possible, you may need to
also make the checkout and publish calls. Checkout on the layout before you upload and publish after. At least in my case this forced the updated files to be downloaded to the player.

Here’s a simple example of the upload with NodeJS RequestJS -library:

UploadToLibrary(file, filepath, mediaID, cb){
var rs = fs.createReadStream(path.normalize(filepath));
if(this.configuration.access_token.length > 1){
var form = new FormData();
form.append(file, fs.createReadStream(filepath));
var headers = {
‘Content-Type’: ‘multipart/form-data’,
‘Authorization’: 'Bearer '+this.configuration.access_token
var options = {
url: this.configuration.url+‘library’,
headers: headers,
name: file,
files: rs
options.formData.oldMediaId = mediaID;
options.formData.updateInLayouts = 1;
options.formData.deleteOldRevisions = 1;
let req = request.post(options, function(err, resp, body){
console.log('ERROR: file upload failed. '+err);

let that = this;
that.UploadToLibrary(file, filepath);
}, 250);

1 Like