GithubHelp home page GithubHelp logo

node-azure-media's Introduction

Azure Media for Node.js

Azure's Media REST API provides a way to store, encode, and deliver media (video and images). This library makes using the API easier.

var AzureMedia = require('azure-media');
var myconfig = require('./myconfig');

var api = new AzureMedia(myconfig); // {client_id: 'your azure media id', client_secret: 'your azure media secret'} 
api.init(function (err) {
    // do your work here or after this callback
});

Install

npm install azure-media

Using Microsoft's Documentation

All of the data structures and endpoints used in this library are documented in Azure Media Service REST API Reference.

Each subsection is modeled based on its "Entity Properties" section (eg. Asset Entity Properties).

Each model usable at API.rest.[lowercase model name] with create, get, update, list methods.

REST Endpoints

All REST endpoints are in the initialized api lib at api.rest.someendpoint (eg. api.rest.asset)

"data" is a JavaScript object for the appropriate endpoint model documented in the Properties section of each model in Azure Media Service REST API Reference.
Callbacks generally return an object, called a model. It uses VeryModel. VeryModel instances behave like normal objects. If you want a simpler object, call .toObject() and use the returned value.

Each endpoint will have some of the following methods:

update

Signature: update(id, data, callback)
Callback: function (err, model)

create

Signature: create(data, callback)
Callback: function(err, model)

Example:

api.rest.asset.create({Name: 'Some Asset'}, function (err, asset) {
    if (err) {
        console.log(err);
    } else {
        console.log("Created asset: " + asset.Id);
    }
});

delete

Signature: delete(id, callback)
Callback: function(err)

get

Signature: get(id, callback)
Callback: function(err, model)

list

Signature: list(callback, query)
Callback: function(err, model)

The query parameter is a JavaScript object of the query parameters documented in OData Query String Options (eg: {'$filter': "Name eq 'Bill'"})

###accesspolicy

AccessPolicys should be reused, rather than just creating a new one for every use. So rather than create, or trying to manage this yourself, use

Signature: findOrCreate(durationInMinutes, permissions, callback)
Callback: function (err, accesspolicy_model)

###assetfileindex ###ingestmanifestasset ###job

Signature: cancel(id, callback)
Callback: function (err)

###locator ###notificationendpoint ###tasktemplate ###asset

###contentkey ###ingestmanifest ###ingestmanifestfile ###jobtemplate ###mediaprocessor ###task

Models

Most callbacks return a VeryModel instance. These are based on Microsoft's documentation and are implemented in /models/

Some models have extra ORM-like methods, allowing you to interact with the model itself which will work with the Azure REST API behind the scenes.

###accesspolicy ###assetfileindex ###ingestmanifestasset ###job ###locator ###notificationendpoint ###tasktemplate ###asset ###contentkey ###ingestmanifest ###ingestmanifestfile ###jobtemplate ###mediaprocessor ###task

Workflow Methods

###uploadStream

api.uploadStream('somefile.mp4', fs.createReadStream('/some/file.mp4'), fs.statSync('/some/file.mp4').size, function (err, path, result) {
}, function (err, path) {
    if(!err) {
        console.log("done uploading");
    }
});

downloadStream

api.downloadStream(assetId, 'video/mp4', fs.createWriteStream('/some/download/path.mp4', function (err) {
});

getDownloadURL

api.getDownloadURL(assetId, 'video/mp4', fs.createWriteStream('/some/download/path.mp4', function (err, url) {
});

encodeVideo

api.encodeVideo(assetId, 'H264 Broadband SD 4x3', function (err, job)) {
});

node-azure-media's People

Contributors

fritzy avatar legastero avatar pankyka avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.