Package Exports
- facebook-business-video-upload
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (facebook-business-video-upload) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
facebook-business-video-upload
Helping to upload video in facebook ad manager.
Usage
Video upload
const fs = require('fs');
const videoUploadEngine = require('facebook-business-video-upload').video;
const options = {
token: "TOKEN",
id: "ID", // page_id or user_id or event_id or group_id
stream: fs.createReadStream('./sample.mp4'), // Video file path,
title: "test video",
description: "test description"
};
videoUploadEngine(options)
.then((response) => {
console.log('\n **********************');
console.log('\n Video Upload Result : ', response); // { success: true, video_id: '987654321' }
console.log('\n **********************');
}).catch((error) => {
console.error(error);
});Image upload
const fs = require('fs');
const imageUploadEngine = require('facebook-business-video-upload').image;
function imageTobase64(filePath) {
// read binary data
let bitmap = fs.readFileSync(filePath);
// convert binary data to base64 encoded string
return new Buffer(bitmap).toString('base64'); // this may give warning. Now working on it
}
const options = {
token: "TOKEN",
id: "ID", // page_id or user_id or event_id or group_id
bytes: imageTobase64('./test.jpg') // Image data in bytes (base64)
};
imageUploadEngine(options)
.then((response) => {
console.log('\n **********************');
console.log('\n Image Upload Result : ', response); // { images: { hash: 'b4345sLKndf34245FDKLn', url:'https://scontent.xx.fbcdn.net/v/t21/32424545gf.jpg?cd=42&fdf=42' } } }
console.log('\n **********************');
}).catch((error) => {
console.error(error);
});