Esri / Esri/arcgis-python-api

copy_raster / _ImageryUploaderAGOL.upload_file fails for raster uploads around 50–60 MB

Open
#2,406 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
2.2k
Forks
1.2k
Avg merge
2h 40m
Merged PRs (30d)
2

Description

**Describe the bug**
When publishing hosted imagery layers using copy_raster() (ArcGIS API for Python 2.4.2), raster uploads around 50–60 MB enter an infinite retry loop inside _ImageryUploaderAGOL.upload_file, never completing. Smaller and larger files upload successfully.

**To Reproduce**
Steps to reproduce the behavior:
```python
from arcgis.gis import GIS
from arcgis.raster import copy_raster

gis = GIS("home")
service_item = copy_raster(
input_raster=r"C:\path\to\raster_51mb.tif",
output_name="test_raster",
gis=gis
)
```
error:
```python
# Process stalls indefinitely repeating upload attempts
# No explicit exception is raised
```

**Expected behavior**
Upload should complete successfully regardless of raster size.

**Platform (please complete the following information):**
- OS: Windows 11 / AWS Lambda (AL2)
- Python API Version: 2.4.2
- azure-storage-blob: 12.17.x
- Python: 3.11

**Additional context**
Cause: upload_blob() performs a single PUT for < 64 MiB files; this often times out and loops indefinitely.
Workaround: Replace the call with manual block upload:
```python
import base64
from azure.storage.blob import BlobBlock
blob = self.container.get_blob_client(blobname)
block_ids = []
with open(file_name, "rb") as f:
i = 0
while chunk := f.read(4*1024*1024):
block_id = base64.b64encode(f"{i:08d}".encode()).decode()
blob.stage_block(block_id, data=chunk)
block_ids.append(BlobBlock(block_id=block_id))
i += 1
blob.commit_block_list(block_ids)
```
This resolves the issue for 50–60 MB rasters.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.