cancel
Showing results for 
Search instead for 
Did you mean: 

upload file with web service

yassine_036
Champ in-the-making
Champ in-the-making
hi i want to know how can i upload file in the company home with web service
can i do this?
or i have to do it with web script
thank you for your help
regards
3 REPLIES 3

eolith
Champ on-the-rise
Champ on-the-rise
Try this:

String contentString = ContentUtils.putContent(new File(rutaFichero));

NamedValue[] contentProps = new NamedValue[2];
contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, nombreFichero);
contentProps[1] = Utils.createNamedValue(Constants.PROP_CONTENT, contentString);
CMLCreate create = new CMLCreate(String.valueOf("file name"), rutaDestino,
      null, null, null, Constants.TYPE_CONTENT, contentProps);

CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });

UpdateResult[] result;
Reference content = null;
result = WebServiceFactory.getRepositoryService().update(cml);

yassine_036
Champ in-the-making
Champ in-the-making
thank you for your help
but i don't understand one thing
what's is : rutadestino, rutaFichero and nombreFichero
it is not inialize in your function
and thank you

eolith
Champ on-the-rise
Champ on-the-rise
Sorry, I'm from Spain and I used spanish language variables.

rutadestino: destination Path
rutaFichero: local file Path
nombreFichero: new document name