Page 1 of 1

RestXpress Working with Images

Posted: Wed May 22, 2013 1:22 pm
by Andrew Gilmour5879596

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


RestXpress Working with Images

Posted: Wed May 22, 2013 2:25 pm
by Maryna Brodina

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


RestXpress Working with Images

Posted: Wed May 22, 2013 2:32 pm
by Andrew Gilmour5879596

Hi Marina,

Do you have any guidance on the base64 decode?

Thanks

Andrew


RestXpress Working with Images

Posted: Wed May 22, 2013 5:22 pm
by Kateryna Grynko

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


RestXpress Working with Images

Posted: Wed May 22, 2013 6:40 pm
by Andrew Gilmour

Hi Katya,

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

Andrew