You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Christopher Cheng <ch...@gmail.com> on 2011/07/19 15:57:34 UTC

getting images directly with alfresco

I am using Alfresco as the repository for images of an image gallery
implemented in Struts.
The problem is that when the html is presented to the client, I want to pass
the direct URL of the image like this

<img src="http://www.mycompany.com/alfresco/download/direct?path=/CompanyHome/Web
Projects/Images/fantasy.jpg"/>

Of course this doesn't work because the ticket "alf_ticket" is not in the
URL and alfresco will take user to the login page.

How could I get the "alf_ticket" with Apache chemistry API?

Re: getting images directly with alfresco

Posted by Peter Monks <pm...@alfresco.com>.
Alfresco's "getContent" CMIS REST API [1] supports a proprietary query string parameter [2] that will execute the request as the "guest" user, without requiring any other authentication credentials.  Provided the guest user has read access to the file you're trying to retrieve, the call will succeed.

Note that this parameter is not part of the CMIS specification - it's an Alfresco-specific feature that's supported for all Alfresco REST APIs (CMIS or otherwise).

Cheers,
Peter

[1] http://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Content_Retrieval_.28getContent.29
[2] http://wiki.alfresco.com/wiki/Web_Scripts#Authenticating   (scroll down to the "Guest Access" sub-heading)
 


On Jul 19, 2011, at 7:05 am, Florian Müller wrote:

> Hi Christopher,
> 
> There is no way to get the "alf_ticket" through OpenCMIS. You have to use the Alfresco APIs to request a ticket.
> But you shouldn't do that. It opens a security hole.
> 
> Better build a proxy servlet that handles the download through OpenCMIS.
> 
> 
> - Florian
> 
> 
> On 19/07/2011 14:57, Christopher Cheng wrote:
>> I am using Alfresco as the repository for images of an image gallery
>> implemented in Struts.
>> The problem is that when the html is presented to the client, I want to pass
>> the direct URL of the image like this
>> 
>> <img src="http://www.mycompany.com/alfresco/download/direct?path=/CompanyHome/Web
>> Projects/Images/fantasy.jpg"/>
>> 
>> Of course this doesn't work because the ticket "alf_ticket" is not in the
>> URL and alfresco will take user to the login page.
>> 
>> How could I get the "alf_ticket" with Apache chemistry API?
>> 
> 


Re: getting images directly with alfresco

Posted by Florian Müller <fl...@alfresco.com>.
Hi Christopher,

There is no way to get the "alf_ticket" through OpenCMIS. You have to use the Alfresco APIs to request a ticket.
But you shouldn't do that. It opens a security hole.

Better build a proxy servlet that handles the download through OpenCMIS.


- Florian


On 19/07/2011 14:57, Christopher Cheng wrote:
> I am using Alfresco as the repository for images of an image gallery
> implemented in Struts.
> The problem is that when the html is presented to the client, I want to pass
> the direct URL of the image like this
> 
> <img src="http://www.mycompany.com/alfresco/download/direct?path=/CompanyHome/Web
> Projects/Images/fantasy.jpg"/>
> 
> Of course this doesn't work because the ticket "alf_ticket" is not in the
> URL and alfresco will take user to the login page.
> 
> How could I get the "alf_ticket" with Apache chemistry API?
>