Update Thumbnail for AGO Item (web map/web app) using python api gis.item.update file not found error

1698
5
Jump to solution
03-12-2021 11:43 AM
EdApalinski
Occasional Contributor

Hi,

I am trying to use the .update(thumbnail) as described in the ArcGIS API for Python

# updating thumbnail
volcanoes_item.update(thumbnail=r'pathway\to\your\directory\IMAGE_NAME.jpg')

 however I am getting a File not found error.  my statement and a copy of the error are below.  Any advise will be greatly appreciated!

Capture.PNG

 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

It looks like you're running the code from an ArcGIS Online Notebook, is that correct?

If you are:

In order for the notebook to access the file you want to update the thumbnail with, the python kernel running in the notebook needs to be able to see that directory. If you're using an AGOL notebook, it's actually in a container on a server machine, and won't have that sort of access.

You'll have to add the files to the file directory that's part of the notebook's container, using the Files tab.

jcarlson_0-1615583928259.png

You can then access that file with the path to the directory in the files tab, or click the "+" icon to add it to a cell in your notebook.

Let me know if you're not using the AGOL / Portal notebook, as that might indicate a totally different problem.

- Josh Carlson
Kendall County GIS

View solution in original post

5 Replies
jcarlson
MVP Esteemed Contributor

It looks like you're running the code from an ArcGIS Online Notebook, is that correct?

If you are:

In order for the notebook to access the file you want to update the thumbnail with, the python kernel running in the notebook needs to be able to see that directory. If you're using an AGOL notebook, it's actually in a container on a server machine, and won't have that sort of access.

You'll have to add the files to the file directory that's part of the notebook's container, using the Files tab.

jcarlson_0-1615583928259.png

You can then access that file with the path to the directory in the files tab, or click the "+" icon to add it to a cell in your notebook.

Let me know if you're not using the AGOL / Portal notebook, as that might indicate a totally different problem.

- Josh Carlson
Kendall County GIS
EdApalinski
Occasional Contributor

Thanks!  I am using an AGOL notebook and adding the file to the files tab in the notebook did the trick!

Best! and have a great weekend!

AaronPaul5
New Contributor II

Hi Josh,

Do you know how to do this in Portal?

Thank you,


Aaron

0 Kudos
Brownschuh
Occasional Contributor II

Piggybacking off of what Aaron requested, I would also like to know how to perform this action in Portal.

 

0 Kudos
jorisfrenkel
Occasional Contributor II

This is not very well documented it seems.

Something like this seems to work though:

from arcgis.gis import GIS
gis = GIS("home")
import requests

olduser = gis.users.get(<username1>)

newuser = gis.users.get(<username2>)

with open("<filename>",'wb') as f:

     f.write(olduser.get_thumbnail())

newuser.update(olduser.access, olduser.preferredView, olduser.description, olduser.tags, r"<filename>", culture=olduser.culture, region=olduser.region)

This is just the basic procedure of course, needs some more work, e.g. getting the correct file type from get_thumbnail_link(), and if possible cutting out the step to save the thumbnail to disk.