java

cancel
Showing results for 
Search instead for 
Did you mean: 
hernandez_jorge
Member II

java

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);
}
}

6 Replies
angelborroy
Alfresco Employee

Re: java

¿Este código produce algún error? En cliente o en servidor.

Hyland Developer Evangelist
hernandez_jorge
Member II

Re: java

Alfresco es la version 5

run:
<?xml version="1.0" encoding="UTF-8"?>
<ticket>TICKET_18fd97bc07172a581bd85bbac85dacb3fc242c7b</ticket>

: <?xml version="1.0" encoding="UTF-8"?>
<ticket>TICKET_18fd97bc07172a581bd85bbac85dacb3fc242c7b</ticket>

numero : 47 -- 94
The upload url:::http://172.16.0.222:8080/alfresco/s/api/upload?alf_ticket=TICKET_18fd97bc07172a581bd85bbac85dacb3fc2...
statusLine>>>404......HTTP/1.1 404 Not Found{
"status" :
{
"code" : 404,
"name" : "Not Found",
"description" : "Requested resource is not available."
},

"message" : "Site (demo) not found.",
"exception" : "",

"callstack" :
[

],

"server" : "Community v5.2.0 (r135134-b14) schema 10,005",
"time" : "Jun 6, 2017 9:29:33 AM"
}


BUILD SUCCESSFUL (total time: 0 seconds)

Gracias por tu ayuda Angel

angelborroy
Alfresco Employee

Re: java

¿Tienes un sitio con el shortname demo creado en Alfresco?

Hyland Developer Evangelist
hernandez_jorge
Member II

Re: java

te envio la Imagen Angel

douglascrp
Advanced II

Re: java

Eso no es un sitio, pero si una carpeta normal.

Usted necesita crear un sitio usando el menu sitios en el menú principal.

Para veer los sitios creados, usted puede acceder la carpeta Sites.

hernandez_jorge
Member II

Re: java

Gracias Douglas y Angel, me salio graciassssssssssss 

Spanish User Group
“Alfresco