How the Database Image URL is generated

How the Database Image URL is generated

  
Hi All

Just sharing to the world how the URLs for database images are created, in case you'll need to usem them on your javascripts.

The way the Agile Platform builds the URL for database images follows the semantics described below:

  • The database image is stored on an ENTITY, with an integer identifier ID, and a binary content FILECONTENT attributes and usually with an image FILENAME set on the image widget. Thus the generated URL for the ESPACE that uses that entity is:
    • http://SERVER/ESPACE/_image.aspx/ENTITY/FILECONTENT/ID/FILENAME
  • Example, the espace DatabaseImage deployed on server myserver, uses database images stored on the entity Image, that has the identifier Id, and the FileContent attributes. The iamge with ID 1 is also named Error_TestQuery.png (also stored on the database, but assigned to the Image Widget in runtime), and the resulting URL is:
    • http://myserver/DatabaseImage/_image.aspx/Image/FileContent/1/Error_TestQuery.png
    • SERVER=myserver
    • ESPACE=DatabaseImage
    • ENTITY=Image
    • FILECONTENT=FileContent
    • ID=1
    • FILENAME=Error_TestQuery.png
Cheers

Miguel Simões João
Hi,

I've been using this without problems in application screens, inside unescaped expressions with some HTML, but now I tried using these in an email, using the "Email Screen", and I always get the "404: not found error". If I send the same content without the link to the images everything works fine.

Does anyone know why this could be happening?

Cheers,
Hermínio Mira
What version of the Agile Platform are you using, Herminio?

Due to security reasons, the way image links are generated in the Agile Platform has changed and in some versions the information in this post might not apply (namely, 7.0+).

But a better question is: why are you using un-escaped expressions to insert images on the Agile Platform instead of using the image widget? With this widget you can be sure that the link will always be generated correctly.
Hi Ricardo,

First of all the problem was in the HTML I was sending, it had a non-existing link... so I'm gonna hide now! :)

I'm using unescaped expressions because this HTML is freely changed by the user in a WYSIWYG editor (CKEditor).

Thanks anyway!
Ricardo Silva wrote:
Due to security reasons, the way image links are generated in the Agile Platform has changed and in some versions the information in this post might not apply (namely, 7.0+).
 
Hello Ricardo,

What is changed in the building of the image url? I've send feedback to support about the security issue, so would be nice to hear something has changed.

Kind regards,
Evert
Evert van der zalm wrote:
 
Hello Ricardo,

What is changed in the building of the image url? I've send feedback to support about the security issue, so would be nice to hear something has changed.

Kind regards,
Evert
 
Hello Evert

We've changed the way the image URL is generated. It now uses hashed tokens instead of image ID's in the URL. This way, it's not possible to iterate the database images by changing the URL.

The breaking change is documented at http://www.outsystems.com/goto/breaking-changes-7.0.

Cheers

Miguel Simões João
Miguel Simões João wrote:
 
Hello Evert

We've changed the way the image URL is generated. It now uses hashed tokens instead of image ID's in the URL. This way, it's not possible to iterate the database images by changing the URL.

The breaking change is documented at http://www.outsystems.com/goto/breaking-changes-7.0.

Cheers

Miguel Simões João
 
 

That's really nice to hear!

Now only need to upgrade to 7.0 (-:

Kind regards,
Evert
Miguel João wrote:
 
Hello Evert

We've changed the way the image URL is generated. It now uses hashed tokens instead of image ID's in the URL. This way, it's not possible to iterate the database images by changing the URL.

The breaking change is documented at http://www.outsystems.com/goto/breaking-changes-7.0.

Cheers

Miguel Simões João
 How/where can i get those tokens? I really need direct URL to images (image widget doesn't work for me)!

Thanks in advance
 
Hi João

You can't get the tokens .. .that was the all point of the security improvement! :)

If you need to have direct access to database images, you can create a page with a download node that fetches the requested image. I believe this pattern is used in the Enterprise Manager 6.0 forge component, if you need a sample of it.

Cheers

Miguel Simões João
"page with a download node that fetches the requested image."

That worked for me!! Problem solved!!

Thank you!
Hello Team,

Can I use "http://<server name>/<espace name>/<web screen>.aspx/<Entity>/<Filename>/<ImageId>/<image name>" as an URL for background-image property for container widget in style script?

for example : in extented property of the container i will give property style and its value will be ""
background-image: url(http://<server name>/<espace name>/<web screen>.aspx/<Entity>/<Filename>/<ImageId>/<image name>);
    
""




Thanks,
Shweta
No.

As discussed previously, that manner of building the URL has been obsoleted by a hashed version which is not possible for you to generate.

If you need to do this, you'll need to make your own download image URL using a REST API, for example.
oops..sorry.. did not go through all the posts:)

thank You for the response.

Hello everybody,

is there any differences in this matter beetwen the Java and .NET stacks?

I'm asking this because i'm having problems with a public webblock that includes a database image. It works well when used in its owner eSpace, but when used in another one it doesn't. And the image url are differents!
This only appens in the Java stack.

Cheers
Hate to kick a dead horse here, but I really need a way to get that image hash token server side.

My scenario is for a rest api: get a list of things, each thing has an image icon. I need that icon url for the response.

Any way to do this? Ricardo, you mentioned 'make your own download image url using a rest api'; may I ask for an example?
The simplest you can do that is to save the images on an entity, create a rest api method with a binary data output which takes an id for that entity and simply gets and outputs the binary data attribute holding the image.
Great method Ricardo. Useful for an app that we are developing.