<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: request a png image using NodeJS and dojo/request from an ArcGIS Server REST feed, and return the image to the client in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317304#M29231</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason there was no word wrap was because the text you pasted was part of a table, so you brought over the table container as well. I have removed the table and the text wraps a little better now. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Dec 2015 18:21:06 GMT</pubDate>
    <dc:creator>TimothyHales</dc:creator>
    <dc:date>2015-12-17T18:21:06Z</dc:date>
    <item>
      <title>request a png image using NodeJS and dojo/request from an ArcGIS Server REST feed, and return the image to the client</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317302#M29229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: 1em;"&gt;I am attempting to request a png image using NodeJS and dojo/request from an ArcGIS Server REST feed, and return the image to the client.&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;I need nodeJS to add a token to the request as a query parameter as my services are secured and I want to control their security through node and not on the resource server (ArcGIS Server 10.3). Without nodeJS in the picture, the png loads in the browser. This is an (open) example of a call returning a png image, using their standard REST feed:&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;&lt;A href="https://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/MapServer/1/images/257104fa1b21d7b483c160ee8f3943bb" rel="nofollow" style="color: #005999;"&gt;https://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/MapServer/1/images/257104fa1b21d7b483c160ee8f3943bb&lt;/A&gt;&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;I am using dojo/request to access this resource. It seems the png image is coming back to node fine, however when I res.send() back to the client, I get a 'not an image' in Fiddler. I can see the PNG header, and the IHDR and IEND in the hexview, however it is apparent that the encoding (? or other) is not the same as when the resource is returned directly from the ArcServer. When the png is received on the client returned from node, the content-length is a little less than when the same png comes directly from the ArcServer. (Node is attempting, by its default, to use Transfer-Encoding: Chunked. I set content-length to the length of the response, so it sends at one time, which I believe is the behaviour the client is expecting.)&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;ESRI (ArcGIS Server) have a new sample stub out which does exactly what I want to do, however they are using esri/request (built on dojo/request) client side, and leverage Blob library to create the correct response for the client.&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;&lt;A href="https://developers.arcgis.com/javascript/jssamples/data_requestArrayBuffer.html" rel="nofollow" style="color: #005999;"&gt;https://developers.arcgis.com/javascript/jssamples/data_requestArrayBuffer.html&lt;/A&gt;&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;We can see they use handleAs: "arrayBuffer", which I have tried on dojo/request and it seems to make no difference to the content of the returned png. When they receive the response, they make a new Blob and then read it as data URL with FileReader (which I have a node side implementation of) and directly use that result as the png.&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;I have tried ad-nausuem to replicate this, but it seems that node does not have a reliable Blob library (I have tried "Blob" with no luck) and I read that in node you are supposed to use Buffers instead. No matter what I pass to fileReader, I get the error "Cannot read as File" (I have tried all fileReader methods). The fileReader library: &lt;A href="https://www.npmjs.com/package/filereader" rel="nofollow" style="color: #005999;"&gt;https://www.npmjs.com/package/filereader&lt;/A&gt;&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;ESRI code:&lt;/P&gt;&lt;PRE class="lang-js prettyprint prettyprinted" style="margin-bottom: 1em; padding: 5px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; color: #393318; background-color: #eeeeee;"&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;esriRequest&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;url&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;handleAs&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;"arrayBuffer"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;}).&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;then&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #00008b;"&gt;function&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;response&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; reader&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;readAsDataURL&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #00008b;"&gt;new&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;Blob&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;([&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;response&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;],&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; type&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;"image/png"&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;}));&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="com" style="color: #808080;"&gt;//reader.result is png ready to use client side&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;});&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin-bottom: 1em;"&gt;My attempts:&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;//tried handleAs: "arrayBuffer"&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;//tried npm Blob library&lt;/P&gt;&lt;PRE class="lang-js prettyprint prettyprinted" style="margin-bottom: 1em; padding: 5px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; color: #393318; background-color: #eeeeee;"&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;request&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;url&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;handleAs&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;"arrayBuffer"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;}).&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;then&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #00008b;"&gt;function&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;response&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #00008b;"&gt;var&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; reader &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #00008b;"&gt;new&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;FileReader&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;();&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; reader&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;addEventListener&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;"loadend"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #00008b;"&gt;function&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;()&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; res&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;setHeader&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;'Content-Type'&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;'image/png'&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;);&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; res&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;setHeader&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;'Content-Length'&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; reader&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;result&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;length&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;);&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; res&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;send&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;reader&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;result&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;);&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;});&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; reader&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;readAsDataURL&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #00008b;"&gt;new&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;Blob&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;([&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;response&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;],&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;{&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; type&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="str" style="color: #800000;"&gt;"image/png"&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;}));&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;});&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin-bottom: 1em;"&gt;I am using node package filereader and Blob, with no luck creating a blob to pass to fileReader. If nodeJS uses Buffers instead of Blob, given that the content returned by the service appears to be an ArrayBuffer png, how do I pass that back to the client, through node?&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;I have also attempted to use ArrayBuffer to Buffer methods (through Uint8Array) however once I have the png in buffer form I can never read it.&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;In short, I just want to proxy the png from its source to the client, adding a token query parameter.&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;Comments welcome to improve the question.&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;originally posted here:&lt;/P&gt;&lt;P style="margin-bottom: 1em;"&gt;&lt;A href="http://stackoverflow.com/questions/34341327/dojo-request-a-png-image-array-buffer-using-nodejs-and-return-the-image-to-the" title="http://stackoverflow.com/questions/34341327/dojo-request-a-png-image-array-buffer-using-nodejs-and-return-the-image-to-the"&gt;http://stackoverflow.com/questions/34341327/dojo-request-a-png-image-array-buffer-using-nodejs-and-return-the-image-to-t…&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2015 18:12:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317302#M29229</guid>
      <dc:creator>TomGiles2</dc:creator>
      <dc:date>2015-12-17T18:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: request a png image using NodeJS and dojo/request from an ArcGIS Server REST feed, and return the image to the client</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317303#M29230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the fact that there is no word wrap applied to my copy+paste leaves me shaking my head.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2015 18:15:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317303#M29230</guid>
      <dc:creator>TomGiles2</dc:creator>
      <dc:date>2015-12-17T18:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: request a png image using NodeJS and dojo/request from an ArcGIS Server REST feed, and return the image to the client</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317304#M29231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason there was no word wrap was because the text you pasted was part of a table, so you brought over the table container as well. I have removed the table and the text wraps a little better now. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2015 18:21:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317304#M29231</guid>
      <dc:creator>TimothyHales</dc:creator>
      <dc:date>2015-12-17T18:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: request a png image using NodeJS and dojo/request from an ArcGIS Server REST feed, and return the image to the client</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317305#M29232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I didn't catch that. I must have copied a table tag from stackoverflow somehow while c+p.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Dec 2015 17:09:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317305#M29232</guid>
      <dc:creator>TomGiles2</dc:creator>
      <dc:date>2015-12-18T17:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: request a png image using NodeJS and dojo/request from an ArcGIS Server REST feed, and return the image to the client</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317306#M29233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: 1em; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;Answered by Dietah on stackoverflow: To get the image in base64 I needed to include&lt;/P&gt;&lt;PRE style="margin-bottom: 1em; padding: 5px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; color: #222426; background-color: #eeeeee;"&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;encoding: null &lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin-bottom: 1em; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;as an option on the request.&lt;/P&gt;&lt;P style="margin-bottom: 1em; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;Answer: &lt;A href="http://stackoverflow.com/questions/34341327/dojo-request-a-png-image-array-buffer-using-nodejs-and-return-the-image-to-the/36182182#36182182" style="color: #358daa;"&gt;http://stackoverflow.com/questions/34341327/dojo-request-a-png-image-array-buffer-using-nodejs-and-return-the-image-to-the/36182182#36182182&lt;/A&gt;&lt;/P&gt;&lt;P style="margin-bottom: 1em; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;I was looking to do a similar action but didn't found any answer. After some trial and error I seem to have figured it out.&lt;/P&gt;&lt;P style="margin-bottom: 1em; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;In your request options add the option encoding: null, this will get the image in a base64 format from the original source.&lt;/P&gt;&lt;PRE style="margin-bottom: 1em; padding: 5px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; color: #222426; background-color: #eeeeee;"&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;request({ url: yoururl, method: 'GET', encoding: null }, function (error, response, body) { if (!error &amp;amp;&amp;amp; response.statusCode === 200) { res.send(response.statusCode, body); } else { res.send(response.statusCode, body.toString('utf8')); } }); &lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin-bottom: 1em; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;Then in my client I did a GET on my own url which gives you the base64 string. For your image on the client you can set the source to data:image/PNG;base64,{result}&lt;/P&gt;&lt;P style="margin-bottom: 1em; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;var result = getBase64FromMyUrl(); var src = 'data:image/PNG;base64,' + result;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Mar 2016 14:23:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/request-a-png-image-using-nodejs-and-dojo-request/m-p/317306#M29233</guid>
      <dc:creator>TomGiles2</dc:creator>
      <dc:date>2016-03-29T14:23:45Z</dc:date>
    </item>
  </channel>
</rss>

