AnsweredAssumed Answered

Uploading a file through JS API

Question asked by alexandreb on May 31, 2017
Latest reply on Jun 7, 2017 by ethan.wong

I'm trying to use the  to build an application (Node) aiming to create files in Alfresco.

I have a Community Edition Alfresco installed.


let AlfrescoApi = require('alfresco-js-api');
let alfrescoJsApi = new AlfrescoApi();

let fs = require('fs');


alfrescoJsApi.login('admin', 'admin').then(function (data) {
        console.log('API called successfully login ticket:' + data);
    }, function (error) {
        console.log("Error, cannot connect to Alfresco");


var fileToUpload = fs.createReadStream('./testFile.txt');

        .then(function () {
            console.log('File Uploaded');
        }, function (error) {
            console.log('Error during the upload' + error);


Previous code doesn't work and I don't know why, I can create a folder with  "  alfrescoJsApi.nodes.createFolder();  " but cannot manage to create a file.
In log I'm obtaining following error :


Error during the uploadError: {"error":{"errorKey":"Required parameters are missing","statusCode":400,"briefSummary":"04310053 Required parameters are missing","stackTrace":"Pour des raisons de sécurité, le traçage de la pile n'est plus affiché, mais la propriété est conservée dans les versions précédente.","descriptionURL":""}}


If anyone have any idea of what I'm doing wrong :/

Thanks in advance