cancel
Showing results for 
Search instead for 
Did you mean: 

get document unique id and read bytes with id?

forumwebuser
Champ in-the-making
Champ in-the-making
Hello,

In my Alfresco repository I have some files with duplicate indexes. At the same time I need to get search results to the client using a custom web service, and then get a specific document form the repository using another custom web service.

Because the search queries will typicall get more than one file (with equal indexes), I would like to get the unique id of each document when the search is executed and then get the document using that same ID. Is this possible?

If yes, from a query result where can I get this id?
And then, to download the document, how can I directly get the document using the id?

thank you.
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
Each node with alfresco has a "NodeRef".   That's the unique key to use.

forumwebuser
Champ in-the-making
Champ in-the-making
Hello,

How can I get that reference?

The goal is to keep a unique string that will be used after to get the document and convert it to a base64 stream.

I tried this but I got an error: unable to get content as inputstream.

However, both the length and the mimetype of the document are, as it seems,  retrieved with success.

            // Use the content service to figure out the URL
            Content readResult[] = contentService.read(new Predicate(new Reference[] {
                new Reference(storeRef, doc_uudi, null)
            }, storeRef, null), Constants.PROP_CONTENT);
           
            content = readResult[0];
           
            logger.debug("length: " + content.getLength());
           
            logger.debug("Mimetype: " + content.getFormat().getMimetype());
           
           
           InputStream in = ContentUtils.getContentAsInputStream(content);