bonjour je suis toujours sur l'upload des fichiers sur java j'arrive les uploader lorsque je donne le chemin en dur mais lorsque je l'exécute avec une page jsp le fichier n'est complet et les pdf et les fichiers word sont corrompu je ne sais d'où vient le problème voici mon code de page jsp: <meta HTTP-EQUIV="Refresh" content="50;URL=http://localhost:8084/xulapps/stage/content/front/index.jsp">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String filename= request.getParameter("y");
String title= filename;
System.out.println("Title est de " +title);
//String ext= filename.substring(filename.lastIndexOf('.')+1, filename.length());
//title= title.replace( filename.substring(filename.lastIndexOf('.'), filename.length()), "");
// System.out.println(ext);
String contType= "";
AuthenticationUtils.startSession("admin", "admin");
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
String folderPath = "/app:company_home";
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.pdf" );
/*System.out.println(filename);
String ext= testecriture.Extension(filename);
title= testecriture.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");
// 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");
CML cml = new CML();
cml.setCreate(new CMLCreate[] {create});
cml.setAddAspect(new CMLAddAspect[] {addAspect});
// Mettre a jour le repositroy
/*if(ext.equals("txt")){
contType= "text/plain";}
else if(ext.equals("pdf")){
contType= "application/pdf";}
else if(ext.equals("doc")|| ext.equals("docx")){
contType= "application/msword";} */
ContentFormat format = new ContentFormat("application/pdf", "UTF-8");
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
Reference content = result[0].getDestination();
InputStream is = request.getInputStream();
byte[] buffer = new byte[32];
ByteArrayOutputStream os = new ByteArrayOutputStream(is.available());
int l;
do {
l = is.read(buffer);
os.write(buffer,0,l);
} while(is.available() > 0);
// le nom du fichier
contentService.write(content, Constants.PROP_CONTENT, os.toByteArray(), format);