AnsweredAssumed Answered

Cannot find uploaded content in company Home

Question asked by oluwasegzy on Aug 1, 2011
Latest reply on Mar 20, 2012 by jpotts
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

Outcomes