I have a script that updates ArcGIS Online item thumbnails from images stored on our web server. We moved the images to a different web server and now the updates are failing with 'Could not identify file'. There is no problem accessing the image via URL. When I compare browser network traces accessing it on the old server and the new server I don't see anything obviously different. I expanded the image to 600x400 since that is the recommended minimum size with no luck. I've attached a script that can be run to recreate the problem. I'm planning on opening a ticket with ESRI, but thought I'd post it here first in case anybody has any ideas. I'm running on Python 3.11.10 from ArcGIS Pro 3.4.0
# To recreate problem
# 1. Update the ITEM_ID variable below to an ArcGIS online item that you own
# 2. Copy this entire script file and paste it into the ArcGIS Pro (make sure you are signed in)python analysis window, hit enter twice
# 3. Enter run_test()
ITEM_ID = '758054a99d934a9d9113d8a5faccf456'
from arcgis.gis import GIS
import requests
def test_upload_as_thumbnail (item, url):
try:
item.update(thumbnail = url)
print (f"Upload {url} to {item.id} as thumbnail succeeded")
except Exception as ex:
print (f"Upload {url} to {item.id} as thumbnail failed: {str(ex)}")
return
def test_download (url):
try:
requests.get(url).content
print (f"Download {url} succeeded")
except Exception as ex:
print (f"Download {url} failed: {str(ex)}")
return
def run_test():
gis = GIS('pro')
for url in ['http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png', # this one works
'https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer_600_400.png', # this one fails
'https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png']: # this one fails
test_download (url)
test_upload_as_thumbnail(gis.content.get(ITEM_ID), url)
Here is the output I get from the test script:
Download http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png succeeded
Upload http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png to 758054a99d934a9d9113d8a5faccf456 as thumbnail succeeded
Download https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer_600_400.png succeeded
Upload https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer_600_400.png to 758054a99d934a9d9113d8a5faccf456 as thumbnail failed: Could not identify file
Download https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png succeeded
Upload https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png to 758054a99d934a9d9113d8a5faccf456 as thumbnail failed: Could not identify file
Solved! Go to Solution.
Seems quite odd alright. Just out of curiosity, does it fail with the Item object update_thumbnail() method too. Docs here.
Edit: I tested and it failed with item.update() but was successful with item.update_thumbnail()
Seems quite odd alright. Just out of curiosity, does it fail with the Item object update_thumbnail() method too. Docs here.
Edit: I tested and it failed with item.update() but was successful with item.update_thumbnail()
Yes! I just tried it myself and it does indeed work. Thanks so much. I'm still curious why it works with one web server but not the other but I'll probably just change my code and move on.