Failing to Upload my AVI file to a Version

Hey Forum!

I’ve been assigned the task to create a script which will take a 360 sequence in Unreal Engine 4, export it and upload it to Shotgun.

I am now currently trying to get my AVI file uploaded to Shotgun in a new Version. I was able to get my script creating a new version, however when I try to upload the file to the Version, it uploads it to “Files” on shotgun and nothing happens to the Version even though I supplied the entity id, as shown in the images below.


The part of my script that creates the version and uploads my AVI file:

def upload():

    filepath = folder + "TurntableShots/" + "turntable.avi" #get avi filepath

    #Get Currently logged in user
    auth = sgtk.authentication.ShotgunAuthenticator()
    user = auth.get_user()
    status = sg.find("HumanUser",[["login","is",str(user)]], fields=["id"])
    userid = str(status).split("\'id\': ",1)[1]     #get rid of unused characters
    userid = userid[:-2]

    data = { 'project': {'type': 'Project','id': int(projectid)}, #Create Version data, for Shotgun API
    'code': filename,
    'sg_status_list': 'rev',
    'user': {'type': 'HumanUser', 'id': int(userid)}}

    if(validasset == "true"):                                     #If asset was inputted add to version data
        data['entity'] = {'type': 'Asset', 'id': int(assetid)}
    if(validdescription == "true"):                              #If description was inputted add to version data
        data['description'] = description

    result = sg.create('Version', data)                           #create version on shotgun
    sg.upload("Version", int(result['id']), filepath)             #upload video to version

    print(filepath + " has been uploaded to Shotgun.")

I have all the correct variables supplied, the “filepath” variable points towards my AVI file.

Yay figured out my issue. I was missing some arguments when using the sg.upload function. I didn’t add the field_name and display_name. Now i’ve updated it to sg.upload("Version", int(result['id']), filepath, field_name="sg_uploaded_movie", display_name="Turntable") everything works and the file is uploaded and linked to the version :slight_smile:

2 Likes