m3dia

1.3.4 • Public • Published

Installing

Using npm:

$ npm install m3dia

Performing a GET TOKEN request

var m3dia = require('m3dia');

var m3 = new m3dia({
    server: 'https://m3dia.gostream.co',
    user: {
        username: 'username',
        password: '123456'
    }
});

(async () => {
    try {
        var token = await m3.getToken();
        console.log(token);
    } catch (e) {
        // Deal with the fact the chain failed
    }
})();

Performing a SET TOKEN request If you have a long time token, instead get token via username and password, you can set it to use.

var m3dia = require('m3dia');

var m3 = new m3dia({
    server: 'https://m3dia.gostream.co',
    token: 'your-long-time-token',
});

(async () => {
    try {
        var data = new FormData();
        data.append('media', fs.createReadStream('/path/to/your/file/filename.mov'));
        data.append('is_convert', 'false');// if you don't need convert to mp4 faststart
        var file = await m3.upload(data);
        console.log("Files: ", file);
    } catch (e) {
        // Deal with the fact the chain failed
    }
})();

Performing a UPLOAD request

var FormData = require('form-data');
var fs = require('fs');
var m3dia = require('m3dia');

var m3 = new m3dia({
    server: 'https://m3dia.gostream.co',
    user: {
        username: 'username',
        password: '123456'
    }
});

(async () => {
    try {
        await m3.getToken();
        var data = new FormData();
        data.append('media', fs.createReadStream('/path/to/your/file/filename.mov'));
        data.append('is_convert', 'false');// if you don't need convert to mp4 faststart
        // if you need use transcode maximum size (support: 360, 480, 720, 1080 )
        // data.append('is_convert', 'true')
        // data.append('maximum_resolution', 720)
        var file = await m3.upload(data);
        console.log("Files: ", file);
    } catch (e) {
        // Deal with the fact the chain failed
    }
})();

Performing a CHUNKING UPLOAD request

var m3 = new m3dia({
    server: 'https://m3dia.gostream.co',
    user: {
        username: 'username',
        password: '123456'
    },
    maxActiveChunk: 5, //default 3
});

(async () => {
    try {
        await m3.getToken();
        var file = await m3.chunkUpload('/path/to/your/file/filename.mov');
        //or if you don't need convert to mp4 faststart
        // var file = await m3.chunkUpload('/path/to/your/file/filename.mov', 'false');
        // if you need use transcode to 480p 
        // var file = await m3.chunkUpload('/path/to/your/file/filename.mov', {isConvert: 'true', isTranscode:'true'});
        // if you need use transcode maximum size (support: 360, 480, 720, 1080 )
        // var file = await m3.chunkUpload('/path/to/your/file/filename.mov', {isConvert: 'true', isTranscode:'true', maximumResolution:1080});
        console.log("\nFiles: ", file);
    } catch (e) {
        // Deal with the fact the chain failed
    }
})();

Performing a GET FILE STATUS request

(async () => {
    try {
        var stt = await m3.getFileStatus([String]fileId)
        console.log("Status: ", stt);
    } catch (e) {
        // Deal with the fact the chain failed
    }
})();

Performing a GET URI request

(async () => {
    try {
        console.log("Files: ", m3.getUri([String]enpoit));
    } catch (e) {
        // Deal with the fact the chain failed
    }
})();

Performing a DELETE FILE request

(async () => {
    try {
        var del = await m3.deleteFile([String]fileId)
        console.log("Delete: ", del.data);
    } catch (e) {
        // Deal with the fact the chain failed
    }
})();

Performing a GET M3DIA LINK FROM YOUTUBE VIDEO ID request

(async () => {
    try {
        var file = await m3.youtubeDownload('your-youtube-id');
        console.log("File: ", file);
    } catch (e) {
        // Deal with the fact the chain failed
    }
})();

Performing a GET M3DIA LINK FROM FACEBOOK VIDEO URL request

(async () => {
    try {
        var file = await m3.facebookDownload('your-facebook-video-url');
        console.log("File: ", file);
    } catch (e) {
        // Deal with the fact the chain failed
    }
})();

Readme

Keywords

none

Package Sidebar

Install

npm i m3dia

Weekly Downloads

7

Version

1.3.4

License

ISC

Unpacked Size

20 kB

Total Files

4

Last publish

Collaborators

  • hunglsx
  • hoptv