cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing the Image Content

sowmiya
Champ in-the-making
Champ in-the-making
I am new to handle the Web Scripts. I tried with the simple web script to access the image content. Here is my sample code of that.

image.get.desc.xml

<webscript>
   <shortname>Image</shortname>
   <description>Image description</description>
   <url>/image</url>
</webscript>

image.get.html.ftl

<img src="/alfresco/d/d/workspace/SpacesStore/37cc4323-710d-4c55-b193-68efdaa9eae4/smiley.gif" alt="Alfresco" />

It works fine when i hit the URL http://localhost:8080/alfresco/service/image after logging in Alfresco correctly.  Smiley Happy

My requirement is to call this URL from other Web application. But it is not working when i call from my other web appliation. I didnt get the image when i hit the URL .  :cry:
Here is my sample JSP code where i try to hit the web script URL.

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Image</title>
</head>
<body>
<a href="http://localhost:8080/alfresco/service/image" > click to view the image</a>
</body>
</html>

Please help me out where am going wrong. Thanks in advance.  Smiley Happy
2 REPLIES 2

openpj
Elite Collaborator
Elite Collaborator
You have to configure your Web Script for a Guest Access:
http://wiki.alfresco.com/wiki/Web_Scripts#Authenticating

In this way you can access to this webscript without authentication, but all the contents must be stored in the Guest Home space in Alfresco.

So you need to add the following element in your descriptor image.get.desc.xml:

<webscript>
<shortname>Image</shortname>
<description>Image description</description>
<url>/image</url>
<authentication>guest</authentication>
</webscript>
And then you have to invoke this webscript using a guest parameter in this way:

<a href="http://localhost:8080/alfresco/service/image?guest=true" > click to view the image</a>
Hope this helps.

sowmiya
Champ in-the-making
Champ in-the-making
Thanks for the reply OpenPj

As per you said, I created the content in Guest Home Space and tried accessing the content straight away by the url
http://localhost:8080/alfresco/d/d/workspace/SpacesStore/96d3871f-0e45-42c2-a34d-21bef469a4ca/homeSm...

Its working fine   Smiley Happy

But when i try to give the same guest=true for the web script that access the content which i mentioned above, its not working  Smiley Sad . I dont know what is the reason behind it. Web script url is  http://localhost:8080/alfresco/service/image?guest=true

Please tell me why that is not working.