cancel
Showing results for 
Search instead for 
Did you mean: 

probleme d'upload de fichier word

yassine_036
Champ in-the-making
Champ in-the-making
bonjour
je suis arrivé à uploader des fichiers pdf et des fichier .txt sans probleme via une page jsp mais la je n'arrive à uploader des fichier word word via la méme page mon code d'upload ajoute une entete au fichier et à l'ouverture du fihcier j'ai un message d'erreur qui me dit voulez-vous installer un composant d'encodage. je ne sais pas c'est quoi le problème
j'espere que vous pourriez m'aider
voici mon code de la page jsp:
 <% 
      
      
       InputStream is= request.getInputStream();
    
     testecriture.ajouter(is, "salut"); // c'est la fonction java qui fait l'upload et salut c'est le titre du fichier
     
    
       %>
    
    </body>

</html>
voici ma fonction java:
   public static void ajouter(InputStream is, String title) throws IOException {
      
      
      
      AuthenticationUtils.startSession("admin", "admin");
      Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
      String folderPath = "/app:company_home/cm:yassine_test";
      ParentReference companyHomeParent = new ParentReference(storeRef, null, folderPath, Constants.ASSOC_CONTAINS, null);

      RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory
            .getRepositoryService();
      ContentServiceSoapBindingStub contentService = WebServiceFactory
            .getContentService();
      NamedValue[] contentProps = new NamedValue[1];
      NamedValue[] titledProps = new NamedValue[2];

      // le nom du fichier
      companyHomeParent.setChildName("{http://www.alfresco.org/model/content/1.0}yassine.doc");
      //String ext= Extension(title);
      //title= replace(title);
      
      CMLCreate create = new CMLCreate("1", companyHomeParent,companyHomeParent.getUuid(), Constants.ASSOC_CONTAINS, null,
            Constants.PROP_CONTENT, contentProps);
      // Construct CML Block
      contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, "yassine.doc");

      // Propriété du fichier
      titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, title);

      titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "");

      CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED,
            titledProps, null, "1");
      
      
      
      String contType = "application/msword";
      /*if(ext.equals("pdf")){
         contType="application/pdf";
      } else if(ext.equals("doc")){
         contType= "application/msword";
      }else if(ext.equals("txt")){
         contType= "text/plain";
      }*/
      
      CML cml = new CML();
      cml.setCreate(new CMLCreate[] { create });
      cml.setAddAspect(new CMLAddAspect[] { addAspect });
      // Mettre a jour le repositroy
      
      ContentFormat format = new ContentFormat(contType, "UTF-8");
      
      UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
      Reference content = result[0].getDestination();

      
      byte[] buffer = new byte[1024];
      ByteArrayOutputStream os = new ByteArrayOutputStream(is.available());
      
      int l = 0;
      while (l >= 0) {
         l = is.read(buffer);
         if (l !=  -1) {
            os.write(buffer, 0, l);
         }
      }
      
       
      is.close();
      os.flush();
      //os.close();
      contentService.write(content, Constants.PROP_CONTENT, os.toByteArray(), format);
merci d'avance de votre aide
cordialement
1 REPLY 1

yassine_036
Champ in-the-making
Champ in-the-making
personne n'a une solution a ce problème ou bien je ne l'ai pas bien expliqué??? Smiley Sad Smiley Sad Smiley Sad
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.