Issues on uploading a .cfg/txt file to GUI Files through API

Hi community,

I need to upload a .cfg/txt file to GUI Files directory through API without success.
The testing file “newfile.cfg” located in “/genieacs/config/ext” can be generated successfully. But I have issues on uploading this file to GUI using API.

Would you please give me some help. Much appreciated.

My code:

const fs = require(‘fs’);
function getConfig (args, callback){

// save template as a .cfg file
fs.writeFile('newfile.cfg', 'this is a testing file', function (err) {
    if (err) throw err;
    // console.log('File is created successfully.');
});

curl -i 'http://http://10.228.228.3:3000/files/OneNewFile.cfg' \
-X PUT \
--data-binary @"./newfile.cfg" \
--header "fileType: 3 Vendor Configuration File" \
--header "oui: 70FC8C" \
--header "productClass: MB425SAV2ad0UFPE4BuNW" \
--header "version: 2.0"

}
exports.getConfig = getConfig;

1 Like