Open and read a TXT file stored in Alfresco

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Established Member

Open and read a TXT file stored in Alfresco

Jump to solution

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 Solution

Accepted Solutions
Highlighted
Master

Re: Open and read a TXT file stored in Alfresco

Jump to solution

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 solution in original post

4 Replies
Highlighted
Master

Re: Open and read a TXT file stored in Alfresco

Jump to solution

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 solution in original post

Highlighted
Established Member

Re: Open and read a TXT file stored in Alfresco

Jump to solution

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

Highlighted
Customer

Re: Open and read a TXT file stored in Alfresco

Jump to solution

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

Highlighted
Intermediate II

Re: Open and read a TXT file stored in Alfresco

Jump to solution

Try

var fileContent = document.content;