<?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: Download File from Geoprocessing Service by URL in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/1583993#M41638</link>
    <description>&lt;P&gt;Thanks for posting this... It's still helping people (me) in 2025!&lt;/P&gt;</description>
    <pubDate>Tue, 11 Feb 2025 14:06:09 GMT</pubDate>
    <dc:creator>BruceBacia</dc:creator>
    <dc:date>2025-02-11T14:06:09Z</dc:date>
    <item>
      <title>Download File from Geoprocessing Service by URL</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/181713#M7191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to download a file created by a Geoprocessing Service. For testing, I created a Service&amp;nbsp;from&amp;nbsp;the&amp;nbsp;script below.&amp;nbsp;The&amp;nbsp;script is having a user supplied input of type String and a derived output of type File.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
input_from_client = arcpy.GetParameterAsText(0)
file = open("testfile.txt","w") 
file.write(input_from_client)
file.close()
arcpy.SetParameter(1, file)&lt;/PRE&gt;&lt;P&gt;I thought that I can simply set the created file as output parameter (arcpy.SetParameter) and would then be able to download it with the returned url.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yet, when running the&amp;nbsp;service with the REST interface, it returns an incorrect url (note the &amp;lt;_io.TextIOWrapper name='testfile.txt' mode='w' encoding='cp1252'&amp;gt; part in the end):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;{
 "paramName": "File",
 "dataType": "GPDataFile",
 "value": {
&amp;nbsp;&amp;nbsp;&amp;nbsp;"url": "https://[nameofserver]/gis/rest/directories/arcgisjobs/excelreportservice_gpserver/j3ddfaa172cc7477288253c965e3c3aba/scratch/&amp;lt;_io.TextIOWrapper name='testfile.txt' mode='w' encoding='cp1252'&amp;gt;"
&amp;nbsp;&amp;nbsp;}
}&lt;/PRE&gt;&lt;P&gt;Any ideas&amp;nbsp;how I can get the correct download url?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would be very&amp;nbsp;thankful&amp;nbsp;for support on this.&lt;/P&gt;&lt;P&gt;Regards, Lukas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:09:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/181713#M7191</guid>
      <dc:creator>LukasWürsch</dc:creator>
      <dc:date>2021-12-12T16:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Download File from Geoprocessing Service by URL</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/181714#M7192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll need to get the path from the TextIOWrapper class:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/475839_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your etParameterAsText line would be&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE&gt;arcpy.SetParameter(1, file.name)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Dec 2019 17:32:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/181714#M7192</guid>
      <dc:creator>JonathanQuinn</dc:creator>
      <dc:date>2019-12-10T17:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Download File from Geoprocessing Service by URL</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/181715#M7193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the reply. I changed the service the way you suggested and this could remove the text wrapper from the url. Now I am getting&amp;nbsp;this url&lt;/P&gt;&lt;PRE style="color: #000000; background-color: #e5eff7;"&gt;https://[nameofserver]/gis/rest/directories/arcgisjobs/excelreportservice_gpserver/j08439162107846f99bc04281f6aa0a36/scratch/test.txt&lt;/PRE&gt;&lt;P&gt;I had a look at the server and noticed that the scratch folder is empty. Do I have to change the script so that the textfile is put to the scratch folder?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2019 10:10:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/181715#M7193</guid>
      <dc:creator>LukasWürsch</dc:creator>
      <dc:date>2019-12-11T10:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Download File from Geoprocessing Service by URL</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/181716#M7194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think i figured it out,&amp;nbsp;&lt;/P&gt;&lt;P&gt;The file has to be created in the scratch folder using &lt;SPAN&gt;arcpy.env.scratchWorkspace variable, then it can be downloaded with the returned url as expected&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;import os&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;input_from_client = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;file = open(arcpy.env.scratchWorkspace+ "/" + "test.txt","w") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;file.write(input_from_client)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;file.close()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;arcpy.SetParameter(1, file.name)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2019 11:00:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/181716#M7194</guid>
      <dc:creator>LukasWürsch</dc:creator>
      <dc:date>2019-12-11T11:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Download File from Geoprocessing Service by URL</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/181717#M7195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, that was very helpful!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Feb 2020 22:13:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/181717#M7195</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2020-02-27T22:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Download File from Geoprocessing Service by URL</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/1583993#M41638</link>
      <description>&lt;P&gt;Thanks for posting this... It's still helping people (me) in 2025!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2025 14:06:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/download-file-from-geoprocessing-service-by-url/m-p/1583993#M41638</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2025-02-11T14:06:09Z</dc:date>
    </item>
  </channel>
</rss>

