cancel
Showing results for 
Search instead for 
Did you mean: 

replace existing file

priyankasoni
Champ in-the-making
Champ in-the-making
hi, i am implementing a action , change file to pdf , so there is need , to replace existing file or content and replace with new file
Can anybody help me How it is possible?
3 REPLIES 3

jpotts
World-Class Innovator
World-Class Innovator
Please read the docs and attempt to overwrite the file on your own. If you have trouble, come back with the stack trace and your source code so we can help you troubleshoot.

If you are doing this remotely and you are using Java, the preferred API is to use CMIS and the docs for that live <a href="http://chemistry.apache.org/java/0.9.0/maven/apidocs/">here</a>.

Jeff

priyankasoni
Champ in-the-making
Champ in-the-making
HI, i have a import a pdf,then i want to make it password protected, for this i write a code, Like

parameter.put(SessionParameter.USER, "admin");
      parameter.put(SessionParameter.PASSWORD, "admin");

      // connection settings
      parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/cmisatom");
      parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());

      // set the alfresco object factory
      parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

      // create session
      SessionFactory factory = SessionFactoryImpl.newInstance();
      Session session = factory.getRepositories(parameter).get(0).createSession();
      CmisObject doc=   session.getObject(id);
ContentStream contentStream = doc.getContentStream();
InputStream inputStream = null;
       inputStream=contentStream .getStream();

  File file = new File("C:/savefile.pdf");

            // get the PDF input stream and create a reader for iText
            PdfReader reader = new PdfReader(inputStream);
            stamp = new PdfStamper(reader, new FileOutputStream(file));

            // encrypt PDF
            stamp.setEncryption(userPassword.getBytes(Charset.forName("UTF-8")), ownerPassword.getBytes(Charset.forName("UTF-8")), permissions, encryptionType);
            stamp.close();


Now i want to replace encrypted  with existing File,How it is possible?Plz help me


kaynezhang
World-Class Innovator
World-Class Innovator
Read Content Management Interoperability Services (CMIS) Specification you 'll find what you need ,you can find Specification  here
http://docs.oasis-open.org/cmis/CMIS/v1.1/cs01/CMIS-v1.1-cs01.pdf