cancel
Showing results for 
Search instead for 
Did you mean: 

Writing To A File in a WebScript

linkinmal
Champ in-the-making
Champ in-the-making
How can I simply write a string (or number) into a file? I tried assigning its content property, and using write() function; but write(string) isn't supported, I couldn't make it work. Should I get its node first?

Thanks.
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
Assuming you want to write to a content property in Alfresco.

You should get a ContentWriter and then call one of the "putContent" methods.   There's one for a String.

linkinmal
Champ in-the-making
Champ in-the-making
I edited the title, I'm trying to do this using Alfresco's JavaScript. I saw ContentWriter thing, but I think it's for Java-backed implementations. Mine is not, it's just a webscript. If it's not java, can you please tell how I can use it in my script?

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
var doc = userhome.createFile("checkmeout.txt");
doc.addAspect("cm:versionable");
doc.content = "original text";

was this helpful?

linkinmal
Champ in-the-making
Champ in-the-making
Yes, thanks Smiley Very Happy I haven't been able to insert my variable yet, but it did add a custom string like "hoeh". Thanks, man.