Select to view content in your preferred language

Geoprocessing service to return a file

4624
10
Jump to solution
07-21-2020 01:50 AM
VictorTey
Esri Contributor

Hi,

How can I get a geoprocessing service to return a file?

I published a GP

if __name__ == '__main__':

    file = open(arcpy.env.scratchWorkspace+ "/" + "test.txt","w")
    file.write("why")
    file.close()
    arcpy.SetParameter(0, file.name)‍‍‍‍‍‍‍‍‍‍‍‍

':

however i kept receiving the 

 "value": "d:\\arcgisserver\\directories\\arcgisjobs\\script_gpserver\\j94a7e5b06f3342deb0ebcb65467f63fe\\scratch/test.txt"

I can see the file in the scratch folder but i need to return the file some how.

I did try to access the file via different permutation of 

https://example.com/arcgis/rest/services/Script/GPServer/Script/jobs/j94a7e5b06f3342deb0ebcb65467f63... to no avail

Can someone kindly assist.

Tags (2)
0 Kudos
10 Replies
LukasHoupt
Emerging Contributor

This is super helpful. I couldn't for the life of me find documentation or other support indicating how to write a layer package or other file to an output parameter and how the server could send that back to the client. Even my ESRI support wasn't aware of this option and was suggesting my server save my output to a network folder. Thanks so much!

0 Kudos