AnsweredAssumed Answered

Geoprocessing service with uploaded zip file that contains an FGDB

Question asked by MollyKFoley on Mar 21, 2018
Latest reply on Apr 2, 2019 by MollyKFoley

I would like to use a user-uploaded zip file in my geoprocessing service. The GP service is called from a Javascript web app, so I need to switch on "uploads" for the GP service. In doing so, it's my understanding that the file will now be uploaded to the server for me, but then I need to get the itemID to pass as a parameter to my GP service. Then in my python script tool, I can do the logic for unzipping and getting the FGDB and go about my merry way.


I feel like I understand the basics but I'm having a really hard time without a sample to look at. Does anybody have a good example of doing this? I'm working with AGS 10.4.1 and Javascript API 4.6. I would really like to see both an example of how the itemID is retrieved and passed to the GP service in the Javascript and then how it is used in the subsequent python script (e.g. is it just "GetParameterAsText()" or "sys.argv[]"?).


While I'm not totally clear on how to retrieve the itemID in the Javascript, I do know you end up passing something like this as a parameter to the service.



How is that then consumed in the python script? If I pass the itemID, will it be translated into the file I actually need? So say I had this script - would the GetParameterAsText actually retrieve the zip file and the below code would execute as expected, or would it just be that itemID and then I have to do something with that itemID to get the actual file associated with it?

import arcpy, os, sys, zipfile

myZipFile = GetParameterAsText(0)
zip_ref = zipfile.ZipFile(myZipFile, 'r')