cancel
Showing results for 
Search instead for 
Did you mean: 

save an existing file on Alfresco to my hard disk

majdi
Champ in-the-making
Champ in-the-making
Hi

I want to download an existing file (on Company Home for example : it's a pdf file) to my hard drive.
How can I do?

thanks
8 REPLIES 8

mikeh
Star Contributor
Star Contributor
Does clicking on the icon not work?

Mike

majdi
Champ in-the-making
Champ in-the-making
Excuse me but I want to do this programmatically.
I succeed to access via webservice.

mikeh
Star Contributor
Star Contributor
Sorry - I misread which forum you'd posted in.

Have you seen WebServiceSample3 in the SDK?

http://wiki.alfresco.com/wiki/Web_Service_Samples_for_Java

Mike

majdi
Champ in-the-making
Champ in-the-making
Thanks

I read it but which I want is that I open this file and save it into the hard drive.
as I understand from the sample the method read or write just read the content.

mikeh
Star Contributor
Star Contributor
If you have a dig a little deeper, you'll see in ContentUtils there's a method copyContentToFile() which should do what you want.

Thanks,
Mike

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi!

I have some different issue but I think that related with. I am trying to access from a Java Application to the repository of Alfresco. I'd like to access files like if they were on the web, e.g: creating an URL("http://localhost.../webdav/file.html) and open it. But I have an 401 HTTP error (I guess because of the authentication). My question is:
    ·Does webDAV doesn't work as a file system when accessing from an external app?
    ·Should I use the "Web_Service_Samples_for_Java"? In this case, should I write/modify this code in my project?
regards and thanks

mikeh
Star Contributor
Star Contributor
Hi

WebDAV should work as you suggest, however you also need to supply the authentication credentials, unless the file is accessible by the guest account.

You can either use HTTP Basic authentication on the WebDAV request for the content, or use web services to obtain a ticket and supply that on the URL.

Thanks,
Mike

alarocca
Champ in-the-making
Champ in-the-making
I had this kind of issue. Even if ContentUtils add the auth ticket to the content url, it will fail if that url is intercepted by an SSO auth filter (eg, NTLM or CAS).

I have NTLM Auth, so what I did is to specify in web.xml the following

<servlet-mapping>
      <servlet-name>downloadContent</servlet-name>
      <url-pattern>/download/*</url-pattern>
   </servlet-mapping>
  
   <servlet-mapping>
      <servlet-name>downloadContent</servlet-name>
      <url-pattern>/ssofreedownload/*</url-pattern>
   </servlet-mapping>

The first pattern is the standard one and NTLM filtered. The second uses the same servlet but is not intercepted by NTLM. Here the auth ticket do its job. Then I get the content url, replace the url-pattern and retrieve it as a stream. Finally you can save it as file where you want.

BR,
Alessandro

Hi!

I have some different issue but I think that related with. I am trying to access from a Java Application to the repository of Alfresco. I'd like to access files like if they were on the web, e.g: creating an URL("http://localhost.../webdav/file.html) and open it. But I have an 401 HTTP error (I guess because of the authentication). My question is:
    ·Does webDAV doesn't work as a file system when accessing from an external app?
    ·Should I use the "Web_Service_Samples_for_Java"? In this case, should I write/modify this code in my project?
regards and thanks