cancel
Showing results for 
Search instead for 
Did you mean: 

Overwriting existing content

ajaswal
Champ in-the-making
Champ in-the-making
Hi,

Is there a way to overwrite the existing content with the same name ? I can search for the existing file and delete it before uploading the updated one. But is there a better way of doing it ? like a flag set to true for overwrite ?


Adnan

Consultant | Object Consulting
3 REPLIES 3

alexcocia
Champ in-the-making
Champ in-the-making
Having the reference to your node file (reference)

ContentFormat contentFormat = new ContentFormat("text/plain", "UTF-8");
WebServiceFactory.getContentService().write(reference, Constants.PROP_CONTENT, "MY NEW CONTENT".getBytes(), contentFormat);

xerox
Champ in-the-making
Champ in-the-making
If you want to override content with the webclient, you need to take the update action instead of the addcontent action.
So go to that document and click on update…


friendly regards,

Nick

shyre
Champ in-the-making
Champ in-the-making
public void actualizarArchivo(String id, String nombre, byte[] contenido, String mime, String encoding){
      RepositoryServiceSoapBindingStub repositoryService = WebServiceClient.getRepositoryService(detail);

      try {
         ContentFormat contentFormat = new ContentFormat(mime, encoding);
         
         Reference actualizado = new Reference(STORE, id, null);

         makeVersionable(repositoryService, actualizado);

         ContentServiceSoapBindingStub contentService = WebServiceClient.getContentService(detail);
         contentService.write(actualizado, Constants.PROP_CONTENT, contenido, contentFormat);
      }
      catch (Exception e){
         log.error("No se ha podido actualizar el archivo");
      }
   }

I use this function to update an existing file, id is the node id, nombre the name of the file to update ex.("hi.txt"), contenido is the file content, and the mime and the encoding for the updated file.