Select to view content in your preferred language

'Could not identify file' updating item thumbnail from URL

274
2
Jump to solution
03-04-2025 11:33 AM
DonMorrison1
Frequent Contributor

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

 

 

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Clubdebambos
MVP Regular Contributor

Hi @DonMorrison1 

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()

Clubdebambos_0-1741120401095.png

 

Download http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png succeeded
Upload http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png to 50261cda83954b8595d3c3427c0c5cb8 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 50261cda83954b8595d3c3427c0c5cb8 as thumbnail succeeded
Download https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png succeeded
Upload https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png to 50261cda83954b8595d3c3427c0c5cb8 as thumbnail succeeded
 
~ learn.finaldraftmapping.com

View solution in original post

2 Replies
Clubdebambos
MVP Regular Contributor

Hi @DonMorrison1 

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()

Clubdebambos_0-1741120401095.png

 

Download http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png succeeded
Upload http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png to 50261cda83954b8595d3c3427c0c5cb8 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 50261cda83954b8595d3c3427c0c5cb8 as thumbnail succeeded
Download https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png succeeded
Upload https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png to 50261cda83954b8595d3c3427c0c5cb8 as thumbnail succeeded
 
~ learn.finaldraftmapping.com
DonMorrison1
Frequent Contributor

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. 

0 Kudos