cancel
Showing results for 
Search instead for 
Did you mean: 

Open and read a TXT file stored in Alfresco

zputnoky
Star Contributor
Star Contributor

Dear All,

Got the following problem to solve. The user should be able to copy a set of property values between different documents. My idea is the following:

  • create a JS script which gets all the properties and their values from the selected content. It does check the content type and only works if the type is matching a certain type.
  • this script is launched from a document library action button called Copy Properties
  • the result should be a simple TXT look alike file in the user's 'My files' folder
  • create another script which should be launched on the target content. This should open the file created by the 1st script, read its content and update the target file properties with the values from the file. The type of the two contents should match to be able to do this. Once the properties are updated, delete the file.

Have all the codes to do the 1st part and the writing of property values.

How can I read a file stored in the 'My files' directoy and get its content?

Regards,

Zsolt Putnoky

1 ACCEPTED ANSWER

afaust
Legendary Innovator
Legendary Innovator

The script API provides access to a node's content via the ScriptNode API. The home folder of a user (their "My Files" location) can be retrieved by accessing the property cm:homeFolder of the node representing the user (the person node) - that can be retrieved via the People API and "people" root object.

View answer in original post

4 REPLIES 4

afaust
Legendary Innovator
Legendary Innovator

The script API provides access to a node's content via the ScriptNode API. The home folder of a user (their "My Files" location) can be retrieved by accessing the property cm:homeFolder of the node representing the user (the person node) - that can be retrieved via the People API and "people" root object.

zputnoky
Star Contributor
Star Contributor

Managed to open the file and read the content. So far so good. Now got another issue to list all the custom properties. Going ahead slowly

Kevin2
Champ in-the-making
Champ in-the-making

Hello,

I have the same problematic but I haven't find the function for read a txt file in ScriptNode API.

Can you help me please ?

Regards

kaynezhang
World-Class Innovator
World-Class Innovator

Try

var fileContent = document.content;