Andrew Gilmour5879596
Posts: 0
Joined: Wed May 22, 2013 1:22 pm

RestXpress Working with Images

Hi,

I have a SQL database which store images. They as stored as a SQL image type and a second column stores the file name as an nvarchar. That all works find. I have the SQL DB linked to RestXpress and can call data. That all works ok. And then I have created a RestService requesting data from my RestXpress server and get the data. How do I display this image? Is there a conversion that I need to make or does an image have to have a url and be hosted elsewhere?

Thanks

Andrew Image

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

RestXpress Working with Images

Hello! You should get either base64 encoded file content or image URL (have to have a url and be hosted elsewhere)

Andrew Gilmour5879596
Posts: 0
Joined: Wed May 22, 2013 1:22 pm

RestXpress Working with Images

Hi Marina,

Do you have any guidance on the base64 decode?

Thanks

Andrew

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

RestXpress Working with Images

Hi Andrew,

You can set image from base64 using the following JavaScript code:
codevar base64data = "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAIAAABvFaqvAAAAN0lEQVQ4jWN8x1TMQAgo7M0iqIaJoAoiwahBowYNT4NYsl59IKjowcqdBNUMPq+NGjRq0KAyCADcBQdiFVwWoQAAAABJRU5ErkJggg=="

Appery("imageComponentName").attr("src", "data:image/png;base64," + base64data);/code

You can also use the following mapping: Image
In mapping click "Add JS" and paste:
codereturn "data:image/png;base64," + value;/code

Andrew Gilmour
Posts: 0
Joined: Sun May 12, 2013 11:14 am

RestXpress Working with Images

Hi Katya,

And it works! Fantastic - many thanks for your help.

Andrew

Return to “Issues”