1
votes

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.

2

2 Answers

0
votes

As you might know the API Is constantly updates It might be that the Open source API for NodeJS is not fully updated

The best way for you to handle Asset Update is to use the REST API its not much more complicated then using the SDK

Example :

MERGE https://media.windows.net/API/Assets('nb:cid:UUID:80782407-3f87-4e60-a43e-5e4454232f60') HTTP/1.1

Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.11
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=youraccountname&urn%3aSubscriptionId=2f84471d-b1ae-4e75-aa09-010f0fc0cf5b&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1337083279&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=DMLQXWah4jO0icpfwyws5k%2b1aCDfz9KDGIGao20xk6g%3d
Host: media.windows.net
Content-Length: 21
Expect: 100-continue

{"Name" : "NewName” }

See the documentation for more info : https://msdn.microsoft.com/en-gb/library/azure/hh974277.aspx#update_an_asset

0
votes

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.