<?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: How to Pass File Directly to esriRequest Instead of Using Form Upload in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229704#M21456</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thomas &amp;amp; John , thank you both for replying but what I need is not loading from from client machine! &amp;nbsp;I need to pass the zip file which is sitting on the server. like referencing to a URL in ajax call&lt;/P&gt;&lt;PRE class="" style="color: #000000; background: #f5f2f0; border: 0px; font-size: 13px; margin: 0.5em 0px; padding: 1em 1em 1em 3.8em;"&gt;&lt;CODE style="border: 0px; font-weight: inherit; font-size: 13px;"&gt;&lt;SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 13px;"&gt;var&lt;/SPAN&gt; data &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit; font-size: 13px;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit; font-size: 13px;"&gt;"www.domain.com/GIS/App.ZIP"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 13px;"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Aug 2017 16:26:30 GMT</pubDate>
    <dc:creator>BehrouzHosseini</dc:creator>
    <dc:date>2017-08-04T16:26:30Z</dc:date>
    <item>
      <title>How to Pass File Directly to esriRequest Instead of Using Form Upload</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229701#M21453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em;"&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;esriRequest&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is used for retrieving data from a remote server or uploading a file. The Request has a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;Form&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;option which is used If the request is to upload a file. We specify the form element that contains the file input control here (As below sample).&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;request&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; url&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; portalUrl &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'/sharing/rest/content/features/generate'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; content&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; myContent&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; form&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; dom&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;byId&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'uploadForm'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; handleAs&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'json'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; load&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; lang&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;hitch&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;response&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;response&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;error&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;errorHandler&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;response&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;error&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; layerName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; response&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;featureCollection&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layers&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layerDefinition&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;addShapefileToMap&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;response&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;featureCollection&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; error&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; lang&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;hitch&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; errorHandler&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em;"&gt;Now, I need to pass a file directly to this options instead of using HTML File Dialog and Input. something like&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; data &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"www.domain.com/GIS/App.ZIP"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token function"&gt;request&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
 form&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; data&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:10:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229701#M21453</guid>
      <dc:creator>BehrouzHosseini</dc:creator>
      <dc:date>2021-12-11T11:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pass File Directly to esriRequest Instead of Using Form Upload</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229702#M21454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This workflow tends to be tricky and the documentation isn't great. &amp;nbsp;What has generally worked for me in the 4.XX version of esriRequest is creating a &lt;A href="https://developer.mozilla.org/en-US/docs/Web/API/FormData"&gt;FormData&lt;/A&gt; and appending a &lt;A href="https://developer.mozilla.org/en-US/docs/Web/API/File"&gt;File&lt;/A&gt; to it, and then passing that FormData in to the query parameter of esriRequest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get the file to begin with,&amp;nbsp;you can access the file input element and look at the .files property to get a list of user selected files, append them to the FormData, and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit - &amp;nbsp;it looks like you're interested in doing this without a file input. &amp;nbsp;I don't think this is really possibly. &amp;nbsp;You can access a file in the browser through drag and drop or a file input. &amp;nbsp;There's no way to provide a path and get back a File object. &amp;nbsp;This would be a security issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 13:03:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229702#M21454</guid>
      <dc:creator>ThomasSolow</dc:creator>
      <dc:date>2017-08-04T13:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pass File Directly to esriRequest Instead of Using Form Upload</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229703#M21455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a similar question that might provide some clues:&amp;nbsp;&lt;A href="https://community.esri.com/thread/107648"&gt;Add attachment without form node&lt;/A&gt;&amp;nbsp; The reason we were able to do this in the mentioned post is because we already had the file/image contents as a blob but, as mentioned by Thomas, obtaining local files directly is as security issue. &amp;nbsp;You might be able to do this if you already have the file object as a blob, maybe obtained from an external server/service or some other API.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:14:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229703#M21455</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2017-08-04T16:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pass File Directly to esriRequest Instead of Using Form Upload</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229704#M21456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thomas &amp;amp; John , thank you both for replying but what I need is not loading from from client machine! &amp;nbsp;I need to pass the zip file which is sitting on the server. like referencing to a URL in ajax call&lt;/P&gt;&lt;PRE class="" style="color: #000000; background: #f5f2f0; border: 0px; font-size: 13px; margin: 0.5em 0px; padding: 1em 1em 1em 3.8em;"&gt;&lt;CODE style="border: 0px; font-weight: inherit; font-size: 13px;"&gt;&lt;SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 13px;"&gt;var&lt;/SPAN&gt; data &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit; font-size: 13px;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit; font-size: 13px;"&gt;"www.domain.com/GIS/App.ZIP"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 13px;"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:26:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229704#M21456</guid>
      <dc:creator>BehrouzHosseini</dc:creator>
      <dc:date>2017-08-04T16:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pass File Directly to esriRequest Instead of Using Form Upload</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229705#M21457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then it's a two step process, first you'll first have to retrieve the file from the mentioned uri (and convert it to a blob/arraybuffer if necessary), then the second step is to use some of the techniques mentioned in the post to send it directly in the form property. &amp;nbsp;How you retrieve the file from the server will depend on the server and what it allows, ideally you can retrieve the file as a blob or arraybuffer as that will simplify the process (&lt;SPAN style="color: #4d4d4d; background-color: #fafafa;"&gt;handleAs:"blob" or handleAs:"arraybuffer").&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:40:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-pass-file-directly-to-esrirequest-instead/m-p/229705#M21457</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2017-08-04T16:40:10Z</dc:date>
    </item>
  </channel>
</rss>

