AnsweredAssumed Answered

How to upload a file from a CUSTOM SHARE PAGE ?

Question asked by paulclinton on Feb 25, 2019
Latest reply on Mar 1, 2019 by paulclinton

Hey guys,


What I have done is that I have integrated a scanner in alfresco. What it actually does is, after scanning the document it uploads it to a folder in the document library. For this I have created a custom share page called scanner and in that I have written a javascript which will get the scanned file and upload.


It works fine. But, what is happening is that I'm hard-coding the username and Password in Ajax POST method and hence all the documents uploaded is getting uploaded under Admin name.


Below is the AJAX method I'm using


username: admin,
password: admin,
url: "/alfresco/api/-default-/public/alfresco/versions/1/nodes/"+alfrescoNodeId+"/children",
method: "POST",
mimeType: "multipart/form-data",
data: form,
async: false,
crossDomain: true,
processData: false,
contentType: false,
success: function(result,status,xhr) {
alert("Content uploaded!");
error: function(xhr,status,error) {
console.log("xhr==== "+xhr);
console.log("status==== "+status);
console.log("error==== "+error);
alert("Error: Failed to upload file");



My question is on how to get the logged in user as the authentication parameters ? Or Is it the right method I'm using to upload the file ?