Search code examples
node.jsrestazure-media-servicesazure-blob-storage

How to update existing media files in Azure Media Services using REST API?


I am using Azure Media Services to build a video hosting and streaming service using Node.js and SailsJS frameworks. I am using REST api and now I have hit a wall that I can't seem to understand: how to update media files in existing assets?

I am using their recommended library for Node.js: https://github.com/fritzy/node-azure-media and while it's outdated and has some annoying bugs, it's still better than building everything by hand. However creating an asset workflow makes a locator for the upload that is different every time. I have a feeling that if I was to create a locator for an existing asset, it will just make a new AssetFile for me. I don't want that. I want to update media linked to the old AssetFile. Something like

function updateAsset(assetId, stream, callback){
    api.rest.asset.update(assetId, {
        Files: [stream]
    }, callback);                                   
}

I suppose I can then run CreateFileInfos and that would replace the old metadata? I have NO idea, this completely standard and common use case is not described or documented ANYWHERE. Can someone advise how to do it?

[UPDATE]: Yeah my feeling was correct. Passing the container to skipper just created another file in that container and Media Services does not register it.

[UPDATE #2]: There is a way to do it by just removing the old asset completely and replacing all of it, but that doesn't solve the problem. What if I have thumbnails stored there that I want to keep? Captions? Moving all of that about is extremely cumbersome. I would like to know how to specifically update the main video.


Solution

  • As part of my profile cleanup, I am answering all old questions:

    The answer to this one is to use the Blob storage REST API to update the relevant Block Blob. Media Services is effectively a wrapper around the Blob Storage, that provides media-related functionality. File-related functionality is still provided by Blob Storage, and after a year of working with Azure, I can say that it is a very common paradigm.