Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

Updating Files

Updating Files

The Backend Services JavaScript SDK allows you to update a file stored by Telerik Platform. This includes two operations: updating the file's metadata and updating the file's content.

Update Metadata

Updating the file metadata can be done by using the same functions used for updating content types.

The following snippet shows how to change the name of an uploaded file and add a custom field in the metadata:

var el = new Everlive('your-app-id');

// update the filename and a custom field in the file's metadata
var file = {
    "Id": "item-id",
    "Filename": "newFileName.png",
    "CustomField": "customValue"
};

el.Files.updateSingle(file)
    .then(function(data) {
            alert(JSON.stringify(data));
        },
        function(error) {
            alert(JSON.stringify(error));
        });

Update Content

Updating the content of a file is done by using the Everlive.Files.updateContent(fileId, file) function. The first argument is the identifier of the file and the second one is the file metadata and the base64 encoded file content.

var el = new Everlive('your-app-id');
var fileId = "file-id=here";

var file = {
    "Filename": "newFileName.png",
    "ContentType": 'image/png',
    "base64": /* the new file content in base64 format */
};

el.Files.updateContent(fileId, file,
    function(data) {
        alert(JSON.stringify(data));
    },
    function(error) {
        alert(JSON.stringify(error));
    });
Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.