cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot find uploaded content in company Home

oluwasegzy
Champ in-the-making
Champ in-the-making
I had just uploaded a file using multipart to the company  home using the java backed webscript but found no file in the Alfresco Company Home.


What  could be wrong. My source code is as below

NodeRef companyHome = repository.getCompanyHome();
      
      String filename = req.getParameter("file");
      
      
      NodeRef writeto = fileFolderService.searchSimple(companyHome, filename);
      
      FormData formData = (FormData)req.parseContent();
      
      
      FormData.FormField[] fields = formData.getFields();
      int count=0;
      for (FormData.FormField field: fields){
         
         System.out.println("Processing item number " + count);
         System.out.println("++++ Am on other fields " + field.getName());
         if(field.getName().equals("file")&&field.getIsFile()){
            System.out.println("++++ My file name is  " + field.getFilename());
            Content content= field.getContent();
            
            InputStream stream = content.getInputStream();
            
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
            
            
            String contents=null;
            
            while ((contents=reader.readLine())!=null){
            
               System.out.println(" Content of File " + contents);
   
               
            
               
         }
            System.out.println("Mimetype +++++++ " + content.getMimetype());
            
            ContentWriter writer= contentService.getWriter(writeto, ContentModel.PROP_CONTENT, true);
             writer.setMimetype(content.getMimetype());
             writer.putContent(content.getInputStream());
            
            
             System.out.println(writer.isClosed());
            
            
            
         }
         count++;

All the println i used were incoporated during my debugging
1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
In looking at your code I'm wondering if you are writing to the content property of the company home folder node, which wouldn't be what you want, instead of creating a new node and writing to the new node's content property.

Jeff