cancel
Showing results for 
Search instead for 
Did you mean: 

Upload to folder fails - Cannot call createNode of Null

shikarishambu
Champ in-the-making
Champ in-the-making
I am trying to upload a file into a folder that is below the company home folder. How do I upload a file to a folder that is one or two levels below the company_home?


upload = companyhome.childByNamePath("/Inbox/").createNode("upload" + "_" + filename,"mymodel:doc", props) ;
upload.properties.content.write(content);
upload.properties.encoding = "UTF-8";
upload.save();

Here Inbox is a folder below the companyhome. This code fails with the following error


Cannot call method "createNode" of null

TIA
4 REPLIES 4

openpj
Elite Collaborator
Elite Collaborator
Probably Mozilla Rhino can't get the instance of that parent node reference because you have wrong the path value.
If you have a subspace named Inbox in the Company Home try to use this path:
Inbox
In this way:
upload = companyhome.childByNamePath("Inbox").createNode("upload" + "_" + filename,"mymodel:doc", props) ;
upload.properties.content.write(content);
upload.properties.encoding = "UTF-8";
upload.save();
Hope this helps.

shikarishambu
Champ in-the-making
Champ in-the-making
No, it does not work. Please do not try to guess the solution. If you have tried and it works then post it.

invictus9
Champ in-the-making
Champ in-the-making
No, it does not work. Please do not try to guess the solution. If you have tried and it works then post it.

1) I have done uploads like this. Openpj's response is not a guess.

2) It might be best if you used the Javascript debugger to find out what is happening with the code that you wrote, rather than trying to read your mind.

shikarishambu
Champ in-the-making
Champ in-the-making
This is what worked for me "Inbox/."