Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

m3dia

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

m3dia

Gostream m3dia cdn SDK

  • 1.3.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

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
    }
})();

FAQs

Package last updated on 13 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc