AnsweredAssumed Answered

Add attachment larger than 10 MBs

Question asked by jskinner-esristaff Employee on Feb 22, 2018

Has anyone had success uploading an attachment larger than 10 MBs to an ArcGIS Online hosted feature service?  I know that this is not possible via a web browser.  I'm trying to upload a video (.mp4) around 50 MBs.  I broke the video into smaller chunks so that each .mp4 is less than 10 MBs.  I tried the following python script using the uploadPart and addAttachment REST functions to achieve this, but keep receiving an error in the addPart function:


{u'error': {u'message': u'', u'code': 400, u'details': [u'Unable to upload item.']}}


Below is my script.  Any help is appreciated.


import requests, json, os

# Disable warnings

# Variables
username = "jskinner_Tred"
password = "****"
id = 1252
TempDir = r"D:\Projects\Treddyfrin\Temp"

# Generate AGOL Token
tokenURL = ''
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': '', 'expiration': 21600}
r =, data = params, verify=False)
response = json.loads(r.content)
token = response['token']

# Register Item
print("Registering Item")
uploadURL = ''
params = {'f': 'pjson', 'token': token, 'itemName': 'attachment1252', 'description': 'Attachment for feature 1252'}
r =, data = params, verify=False)
response = json.loads(r.content)
itemID = str(response['item']['itemID'])

# Upload Parts of video to Registered Item
def addPart(itemID, token, filename, num):
    '''Add part of the input video using a post request through the request module'''

    print("Adding parts of video")

    addpartURL = '' + itemID + '/uploadPart'
    params = {'token':token, 'f':'pjson', 'partNumber': str(num)}
    image = {'partFile': (os.path.basename(filename), open(filename, 'rb'), 'video/mp4')}
    response =, data = params, files = image)

# Walk through temp directory to get each video part
for a, b, c in os.walk(TempDir):
    for name in c:
        index = int(name.replace('output', '').replace('.mp4', ''))
        addPart(itemID, token, os.path.join(TempDir,name), index)

# Commit upload
print("Commiting upload")
commitURL = '' + itemID + '/commit'
params = {'f': 'pjson', 'token': token}
response =, data = params)

# Add attachment to feature
print("Adding attachment to feature")
fsURL = '' + str(id) + '/addAttachment'
params = {'f': 'pjson', 'token': token, 'uploadId': itemID}
response =, data = params)