cancel
Showing results for 
Search instead for 
Did you mean: 

How can I save files on my filesystem ?

pierropl
Champ in-the-making
Champ in-the-making
Hi
I'm using Java classes. I want to save files on my file system from Alfresco Repository.
I use the following code ( example query2.java):

String nodeId = row.getNode().getId();
                       //Reference reference = new Reference(STORE,nodeId, null);
                       
                        ContentResult contentResult = new ContentResult(nodeId);
                       
                          Content[] readResult = contentService.read(
                                                new Predicate(new Reference[]{reference }, STORE, null),
                                                Constants.PROP_CONTENT);
                                               
                                                Content content = readResult[0];
                                               
                                               
                               
                                           File f=new File("funziona.txt");
                                              
                                               System.out.println(content);
                                              ContentUtils.copyContentToFile(content,f);


I am not able to save file on my file system.
Problem is in  ContentUtils.copyContentToFile method.

I have the following error:
/app:company_home/*[@cm:name="sal"]
org.alfresco.webservice.content.Content@3e3f4660
Exception in thread "main" java.lang.RuntimeException: Unable to perform search.

        at org.alfresco.sample.webservice.Query2.getRankedContent(Query2.java:24
2)
        at org.alfresco.sample.webservice.Query2.main(Query2.java:89)
Caused by: org.alfresco.webservice.util.WebServiceException: Unable to get conte
nt as inputStream.
        at org.alfresco.webservice.util.ContentUtils.getContentAsInputStream(Con
tentUtils.java:115)
        at org.alfresco.webservice.util.ContentUtils.copyContentToFile(ContentUt
ils.java:130)
        at org.alfresco.sample.webservice.Query2.getRankedContent(Query2.java:18
😎
        … 1 more
Caused by: java.net.MalformedURLException: no protocol: null?ticket=TICKET_a1db1
e8b-007f-11db-8fde-054c7e2948dc
        at java.net.URL.<init>(URL.java:567)
        at java.net.URL.<init>(URL.java:464)
        at java.net.URL.<init>(URL.java:413)
        at org.alfresco.webservice.util.ContentUtils.getContentAsInputStream(Con
tentUtils.java:109)
        …

Can you help me?  Smiley Happy

Thanks
Luca
1 REPLY 1

srikanth
Champ in-the-making
Champ in-the-making
hello Mr.Luca

ContentResult–> where can i find this class.
Plz tell me the lib file.