cancel
Showing results for 
Search instead for 
Did you mean: 

How to get download link url using cmis

sibi_thomas
Champ in-the-making
Champ in-the-making
Hi,

can somebody help me for getting the content and its download link url using cmis.

we are using alfresco 3.2 version
1 REPLY 1

malliswar
Champ in-the-making
Champ in-the-making
here is the i used in my java application to read the content in a file which is in alfresco repository

this program create a file and dumps the data in alfresco-repository file into newly created file

import java.awt.List;
import java.io.*;
import java.net.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;

import org.apache.commons.codec.binary.Base64;


public class UrlDownload {
    final static int size=1024;

    public static void  fileUrl(String fAddress) {
    OutputStream outStream = null;
    URLConnection  uCon = null;

    InputStream is = null;
    try {
        URL Url;
        byte[] buf;
        int ByteRead,ByteWritten=0;
        Url= new URL(fAddress);
        System.out.println("URL=====>"+Url);
        outStream = new BufferedOutputStream(new FileOutputStream(null));

        uCon = Url.openConnection();      
        //String encode=new Base64().encodeToString("admin:Welcome@123".getBytes());      
        uCon.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
      
        is = uCon.getInputStream();
       
        buf = new byte[size];
        while ((ByteRead = is.read(buf)) != -1) {
            System.out.print((char)ByteRead);    
            outStream.write(buf, 0, ByteRead);
            ByteWritten += ByteRead;
        }
       
    }catch (Exception e) {
        e.printStackTrace();
        }
    finally {
            try {
            is.close();
            //outStream.close();
            }
            catch (IOException e) {
        e.printStackTrace();
            }
        }
}
public static void main(String[] args)
    {
   fileUrl("http://172.18.0.96:8080/alfresco/service/api/node/workspace/SpacesStore/b5a3d55b-a582-4895-9cc3-d434...");
   
    }
}