Actually, we are not responsible for any 3rd party libraries/modules, however, seems like it should work on the server. You need to create/generate a BL project and deploy it on our servers.
how can i instruct the JS server code to export a file to Files?
'use strict';
class SplitVideo {
/**
* @param {String} name
* @returns {String}
*/
SplitVideoMethod(name) {
let MediaSplit = require('../node_modules/media-split');
let split = new MediaSplit({
input: 'https://www.youtube.com/watch?v=qbRqySW39TI&ab_channel=RoCarsRoCars',
sections: ['[00:01 - 00:03] Myfile'],
format: 'mp4',
output: ''// <------ Here i should point to where to save the file
});
split.parse().then((sections) => {
for (let section of sections) {
console.log(section.name); // filename
console.log(section.start); // section start
console.log(section.end); // section end
console.log(section.trackName); // track name
}
});
}
}
SplitVideo.version = '1.0.0';
Backendless.ServerCode.addService(SplitVideo);
Hey
following you advice i was able to tested debug the method locally successfully but when i deploy there is no output and there is no errors in the log file.
is there anything i can do to debug the issue?
here is the code that work locally and with remote debug successfully
'use strict';
class SplitVideo {
/**
* @param {String} name
* @returns {String}
*/
async SplitVideoMethod(name) {
let MediaSplit = require('../node_modules/media-split');
const fs = require('fs');
const path = require('path');
let currentDirectoryPath = __dirname;
let myAppRootDirectoryPath = path.resolve(__dirname, '../../../../../');
Backendless.Logging.setLogReportingPolicy( 1, 1 );
var logger = Backendless.Logging.getLogger( "MyLogger");
logger.info( myAppRootDirectoryPath );
let split = new MediaSplit({
input: myAppRootDirectoryPath+'/ads_service/0391E4B39-D876-40A3-A48F-E42A74B05770.mp4',
sections: ['[00:01 - 00:03] Myfile'],
format: 'mp4',
output:myAppRootDirectoryPath
});
split.parse().then((sections) => {
for (let section of sections) {
logger.info( 'File Exported' );
}
});
}
}
SplitVideo.version = '1.0.0';
Backendless.ServerCode.addService(SplitVideo);
This is the log when i invoke the service:
2021-06-10 20:11:52,402 | SERVER_CODE | INFO | [16609] ServerCode Model built in 7ms
2021-06-10 20:11:52,408 | SERVER_CODE | INFO | [16609] [347FBCFF-B1DE-1B48-FFF4-5CCE31AEE100] [INVOKE SERVICE] services.SplitVideo.SplitVideoMethod
2021-06-10 20:11:52,484 | MyLogger | INFO | /opt/backendless/repo/07d0cc0c-4a50-198b-fffb-78866ccd9600/files
2021-06-10 20:11:52,489 | SERVER_CODE | INFO | [16609] Processing finished in 102.807ms
in case you need my app id: 07D0CC0C-4A50-198B-FFFB-78866CCD9600
I’m so sorry but seems like I was pointing you the wrong way.
There is no way to write directly on the File Storage using Nodejs API, the only way is to use Backendless.Files API.
is there a reason why we cant create a file on the server from a script that is running on the server? cant you guys add this feature?
its super useful and adds a lot of possibility to backendless