cancel
Showing results for 
Search instead for 
Did you mean: 

Display an image from the repository in a web page

denz
Confirmed Champ
Confirmed Champ

Hi,

This is simply question from a newbie :

- how can I display an image from the repository in a web page ? (without login...) 

(for example on a webpage <img src="myimage.jpg">)

Actually,

I've got a webscript "MyWebScript" that I can't modidy (I don't have access to the server system), but I override it with Share (in "/Company Home/Data Dictionary/Web Scripts/MyWebScript")

It works fine with the page.get.html.ftl file (and others) but doesn't work to override a JS script

I've got an amp file and I found this :

In one hand i've got :

\alfresco\config\alfresco\extension\templates\webscripts\fr\MyWebScript\page.get.html.ftl (and other files)

and in the other hand i've got :

\alfresco\source\web\scripts\MyWebScript\myscript.js (and other files)

My second question is "How can override "myscript.js" from share ?"

I tryed many ways but all failed.

Thanks a lot to help me to find anwsers to this 2 questions (hope you understand me -_-')

____________

Wtih Alfresco Community 4.2.f

5 REPLIES 5

kaynezhang
World-Class Innovator
World-Class Innovator

I'm sorry I'm not clear about what you mean.
I guess you can implement an proxy servlet in your application ,in your proxy servlet download the image from alfresco server using opencmis api or webscript api and then display it in a web page.

Thank you for trying to help me.

First of all, I'd just like to display an image (put in my repository "/Company Home/Data Dictionary/Web Scripts/MyWebScript" or in Guest space...), in a web page with <img src="myimage.jpg" />

I tryed https://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom/content?id=f2b90ae5-b590... 

but Alfresco asks credentials...

after, it displays :

  "status" :    {     "code" : 401,     "name" : "Unauthorized",     "description" : "The request requires HTTP authentication."   },        "message" : "10230046 Authentication failed for Web Script org\/alfresco\/api\/opencmis\/OpenCMIS.get",

Secondly, I'd like to override JS Script of my webscript (URL is "/alfresco/scripts/myscript/validate-fields-config.js")

denz
Confirmed Champ
Confirmed Champ

Anybody knows ? (or understands what i meant ?)

Thx

kaynezhang
World-Class Innovator
World-Class Innovator

Almost all of the URL request to alfresco requires authentication,you can't use it like <img src="myimage.jpg" /> directly.

Only after login and get a login ticket then you can visit url https://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom/content?id=f2b90ae5-b590....


What you need to do is to use a proxy servlet,in your proxy servlet:
you can login to alfresco and get the ticket or you can just download the image.

denz
Confirmed Champ
Confirmed Champ

I found a solution that works with any file, but I don't know if it's a good way.

  1. put your file on a repository
  2. click on "Share" (displays something like https://localhost/share/s/TqGniKKbRMiFtwOtdkwZQg)
  3. Paste the URL and keep the last string (ex: TqGniKKbRMiFtwOtdkwZQg)
  4. Use the URL's file like this:

    https://localhost/share/proxy/alfresco-noauth/api/internal/shared/node/YOURSTRING/content/NAMEFILE

    YOURSTRING is for ex TqGniKKbRMiFtwOtdkwZQg
    YOURNAME is the name you want to the file

Then you can for example display an image from Alfresco repository like this :

<img src="https://localhost/share/proxy/alfresco-noauth/api/internal/shared/node/TqGniKKbRMiFtwOtdkwZQg/conten..." />

WARNING : When you share the file, it becomes a public file ! So becareful what you share