AnsweredAssumed Answered

java

Question asked by hernandez.jorge on Jun 5, 2017
Latest reply on Jun 6, 2017 by hernandez.jorge

como logro agregar archivos al Alfresco a travez de java?

he realizado este codigo, pero aun no logro insertar documentos 

mi correo es :hernandez.jorge51@gmail.com

Gracias

public void uploadDocument(String authTicket, File fileobj, String filename, String filetype, String description, String destination) {
try {
String urlString = "http://172.16.0.222:8080/alfresco/s/api/upload?alf_ticket=" + authTicket;

System.out.println("The upload url:::" + urlString);
HttpClient client = new HttpClient();
PostMethod mPost = new PostMethod(urlString);

Part[] parts = {
new FilePart("filedata", filename, fileobj, filetype, null),
new StringPart("filename", filename),
new StringPart("description", "description"),
new StringPart("siteid", "demo"),
new StringPart("containerid", "documentlibrary"),

};
mPost.setRequestEntity(
new MultipartRequestEntity(parts, mPost.getParams())
);
int statusCode1 = client.executeMethod(mPost);
System.out.println("statusLine>>>" + statusCode1 + "......" + mPost.getStatusLine() + mPost.getResponseBodyAsString());
mPost.releaseConnection();

} catch (Exception e) {
System.out.println(e);
}
}

Outcomes