Select to view content in your preferred language

Geoprocessing service to return a file

6660
12
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
12 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
DougBrowning
MVP Esteemed Contributor

I know this is old @BruceHarold  but on server 11.3 Scratch Workspace is not giving back the job dir from arcgisjobs dir.  Instead it is giving and writing to AppData under the user name.  This dir is not part of the cleanup schedule and it growing over time.

arcpy.AddMessage("Scratch Workspace " + arcpy.env.scratchWorkspace)

Scratch Workspace C:\Users\serveruser~1\AppData\Local\Temp\aim\speedtest_gpserver\j9b2d66b7a00d4a8696d2fe7973da3ba4\scratch

The post in here shows it should be my arcgisjobs dir right?

I am even seeing it create the jobs dir with a scratch folder in the arcgisjobs folder and even a scratch GDB but it does not use it.  I can find no way in script to find this jobs dir either.

DougBrowning_0-1734018741952.png

Why is it not using arcgisjobs as configured both in the GP tool and in the server settings?

thanks

0 Kudos
BruceHarold
Esri Regular Contributor

H Doug, can you please open a  support call.  I know that sounds like a canned response but in this case we'll have to rope in geoprocessing team and they need something to track for their work.  Thanks for reaching out.