AnsweredAssumed Answered

Can you not use gis.content.add() with *.shp but only *.zip?

Question asked by agelfert on Jan 25, 2019
Latest reply on Jan 25, 2019 by Dan_Patterson

I was reading the following as a convenience feature:

If you have a small amount of data in a shapefile, you can make it available for others to view through a web browser by adding it as a .zip file containing the .shp.shx.dbf, and .prj files to a map you create with Map ViewerShapefiles—Portal for ArcGIS | ArcGIS Enterprise 

But it looks like the following really doesn't work:

county_properties = {'title':'Active Counties',
                    'tags':'counties, rigs, portal upload test',
counties_shp = mygis.content.add(county_properties, data='c:/temp/counties.shp')

Error while analyzing Shapefile 'counties.shp' Invalid Shapefile

Then, however, I can do this:

import zipfile
import glob, os

shpDir = 'c:/temp'
nametrunc = 'counties*'

files = glob.glob(os.path.join(shpDir,nametrunc))

with zipfile.ZipFile(os.path.join(shpDir,''), 'w') as myzip:
   for file in files:

counties_shp = mygis.content.add(county_properties, data='c:/temp/')

I haven't had to upload a bunch of SHP files to Portal but it sure would be easier if you didn't have to zip them up.