cancel
Showing results for 
Search instead for 
Did you mean: 

Download a file (.txt, .jpg, .pdf) to the client computer

coreques
Champ in-the-making
Champ in-the-making
Hi

I´m working with Alfresco since two weeks ago, in a java aplication for a desk client and am using openCMIS.

At the moment I am able to upload and delete all type of the files that I need in my aplication (.txt, .jpg, .pdf), but when try to download them to the client computer I do not know how to do it. I have been  reading in a lot of places but I do not see anything that be useful for me.

Can you give me some help to start or recomend a place to read about it?

Thank you very much and regards.
2 REPLIES 2

cnarvaez
Champ in-the-making
Champ in-the-making
Hi when you build the descktop application could call webdav Services from Alfresco to make this or could using CMIS.

muralidharand
Star Contributor
Star Contributor
Here is the code snippet.
<java>

string objectId = <Document Object ID> goes here
            try
                {

                    Document doc = session.GetObject(objectId) as Document;
                    ContentStream contentStream = (DotCMIS.Data.Impl.ContentStream)doc.GetContentStream();
                    using (var fileStream = File.Create(@".\" + contentStream.FileName))
                    {
                        contentStream.Stream.CopyTo(fileStream);
                    }
                    MessageBox.Show("File " + contentStream.FileName + " downloaded successfully");
                }catch(Exception ex)
                {
                    MessageBox.Show("File " + fileName + " download failed." + ex.Message);
                }

</java>
Download the sample application at https://github.com/muralidharand/AlfrescoDotCMISExamples