AnsweredAssumed Answered

Erreur d'upload

Question asked by davtrasher on Aug 5, 2008
Latest reply on Aug 20, 2008 by davtrasher
Bonjour,
Je tente d'uploader des fichiers vers alfresco 2.9c avec les apis rest. L'upload réussi mais les fichiers sont illisibles.
méthode post:
String adresse= "/alfresco/wcservice/sample/upload?";
      try {
         //encodage des paramètres de la requête
         String donnees = URLEncoder.encode("filename", "UTF-8")+
         "="+URLEncoder.encode(nomDoc, "UTF-8");
         donnees += "&"+URLEncoder.encode("content", "UTF-8")+
         "=" + URLEncoder.encode(content, "UTF-8");
         donnees += "&"+URLEncoder.encode("mimetype", "UTF-8")+
         "=" + URLEncoder.encode(mimetype, "UTF-8");
         donnees += "&"+URLEncoder.encode("title", "UTF-8")+
         "=" + URLEncoder.encode(title, "UTF-8");
         donnees += "&"+URLEncoder.encode("description", "UTF-8")+
         "=" + URLEncoder.encode(description, "UTF-8");
         donnees += "&"+URLEncoder.encode("TypeExam", "UTF-8")+
         "=" + URLEncoder.encode(TypeExam, "UTF-8");
         donnees += "&"+URLEncoder.encode("nodeid", "UTF-8")+
         "=" + URLEncoder.encode(nodeid, "UTF-8");
         donnees += "&"+URLEncoder.encode("ticket", "UTF-8")+
         "=" + URLEncoder.encode(getTicket(), "UTF-8");

         //création de la connection
         URL url = new URL(getUrlContext()+adresse);
         URLConnection conn = url.openConnection();
         conn.setDoOutput(true);

         //envoi de la requête
         writer = new OutputStreamWriter(conn.getOutputStream());
         writer.write(donnees);
         writer.flush();

         //lecture de la réponse
         reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
         while ((ligne = reader.readLine()) != null) {
            System.out.println(ligne);
         }

webscript upload:
var filename = null;
var content = null;
var title = "";
var description = "";
var nodeid = "";
var TypeExam = "";
var mimetype = "";

// locate file attributes
filename = args['filename'];
content = args['content'];
mimetype = args['mimetype'];
title = args['title'];
description = args['description'];
nodeid = args ['nodeid'];
TypeExam = args['TypeExam'];

// ensure mandatory file attributes have been located
if (filename == undefined || content == undefined)
{
  status.code = 400;
  status.message = "Uploaded file cannot be located in request";
  status.redirect = true;
}
else
{
// get folder to upload into with nodeid
if ((nodeid) && (nodeid != ""))
{
   model.folder = search.findNode("workspace://SpacesStore/" +nodeid);
}
      upload = model.folder.createFile(filename) ;
            upload.specializeType("{my.new.model}compte_rendu");
            upload.properties.content.write(content);
            upload.properties.content.encoding = "UTF-8";
            upload.properties.content.mimetype = mimetype;
               upload.properties.title = title;
               upload.properties.description = description;
            upload.properties.TypeExam = TypeExam;
               upload.save();

  // setup model for response template
  model.upload = upload;
}
Quand j'utilise upload.properties.content.write(content), j'ouvre le document il contient ceci "Le contenu de l'élément est manquant :
   élément : workspace://SpacesStore/636eb6a8-623d-11dd-948f-7b708f4f69e0
   lecteur : null
Veuillez contacter votre administrateur système."

Quand j'utilise upload.properties.content.setcontent(content) le document fait la bonne taille, a le bon nombre de page, mais je n'obtient  que des pages blanches.

D'après vous l'erreur viendrait plutot du script ou du code? Merci

Outcomes