2

I am calling an API on Azure, that itself is calling a thumbnail (Jpeg) using this API:

https://api-portal.videoindexer.ai/docs/services/Operations/operations/Get-Video-Thumbnail/console

However, the results come out like below:

����Lavc58.18.100��C                    


���
1!QAa"q2B���R�#3br��u�����S6C$%��5�cts�T&D4��U��d���e!1AQa2"q�#����3��B���X"��?��!=��W�u�ٗ�-2���?����ۯ�Կ�i���t����M���Y�-��-Vdϊ�P�<�<U#TY]K��dW
���
�ϥ�U�{,!<�J�¶ȵ��k$e�9-[b��&��e�-�ϑ"�V��m�,�]4,m��]-�,�Є(�4-X��H�-���"�Bҋ-E�$l�Ѯ
y�ÃU�Ltj��+b�cu����d�u��8x_{'w��)���Z��ز,�@�D]D�l[t"�2�,Qd^��)f��b�aB�@�!�!�!�!�!�!�!�!�!5�.x-���@-X�*!�$������O����c���f
���5���v�{t���$�U��~���m��j_�����W�
���K

I am calling the video indexer API above (in the backend) and defining var img = <img src=\"${result}\"> where result is effectively the characters above (which I have shortened), but should be the image.

I then want to show this on a web page, currently, I am attempting to use:

context.res = {
    body: img,
    headers: {
        'Content-Type': 'text/html; charset=utf-8'
    }
} 

I have also attempted to use:

context.res = {
    body: img,
    headers: {
        'Content-Type': 'image/Jpeg'
    }
} 

where var img = result

but it is not working - when calling my API on web it is returning the symbols in the example above and not the image.

I believe the issue is in the way I am handling the image in the backend, and passing it along as symbols as opposed to the image being passed along, (perhaps encoding?), but I haven't had to deal with something like this before.

Any tips on how to go forward?

I am using MS Azure and node.js.

JDT
  • 965
  • 2
  • 8
  • 20
  • Can you profile Azure response? I want to see `Content-Type` and `charset` :) – svltmccc Jan 30 '20 at 13:02
  • 1
    `src` expects to be given a URL, not the raw binary data of the image – Quentin Jan 30 '20 at 13:07
  • @SaveliTomac sorry I don't understand – JDT Jan 30 '20 at 13:40
  • @Quentin Hi, I have had a look at the solution you sent, but I am unsure how exactly that applies in this situation, the data uri data sent in your solution seems to be a string of letters/numbers etc whereas I have symbols. Can you explain please? – JDT Jan 30 '20 at 14:03

0 Answers0