cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain document name with REST call

spilby
Confirmed Champ
Confirmed Champ
I'm downloading a content from alfresco with RESTFull calls. First I obtain the ticket and then I call the DownloadServlet alfresco/download/attach/workspace/SpacesStore/GUID/documentName.

The problem is that I don't know previously the documentName. If I put an invented name (for example, "document") the content is download with this name, but I want the real name that is stored in alfresco.

The unique way is calling before a "GET /alfresco/service/api/metadata?nodeRef=workspace://SpacesStore/GUID" service to obtain the metadata and the name property? Or there are a best option to know the name of the document to download it with this?


Thank you very much!
2 REPLIES 2

sanket
Champ on-the-rise
Champ on-the-rise
There is only one line code to get the document name; if you have the nodeRef of the document.
String fileName = getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME).toString();

spilby
Confirmed Champ
Confirmed Champ
Well, in this case, I don't use the Alfresco API. Only REST calls. My code is outside a webscript. Is the reason to use /alfresco/service/api/metadata. Works ok, but for a best performance, I want to know if it's the best solution to obtain the name.