Frame.io old api v2 to v4

how do I fix these python functions from the old v2 to api v4?

def frameCrateFolder(frameProject,frameNewFolder):

   from frameioclient import FrameioClient

   TOKEN=("xxxxxxx")

   client = FrameioClient(TOKEN)

   # Create a folder:

   asset = client.assets.create(parent_asset_id=frameProject,,name=frameNewFolder,type="folder")

   return asset



def uploadToFrame(destination_id,fileToUpload):

   from frameioclient import FrameioClient

   TOKEN=("xxxx")

   client = FrameioClient(TOKEN)

   upload=client.assets.upload(destination_id, fileToUpload)

   return upload

Hi @piroP!

First thing to mention is we have a new Python SDK for V4. You can find the reference here in the docs: Python SDK Reference | Frame.io API Documentation

To create a folder:


from frameio import Frameio
from frameio.folders import FolderCreateParamsData

client = Frameio(
    token="YOUR_TOKEN",
)
client.folders.create(
    account_id="YOUR_ACCOUNT_ID",
    folder_id="ROOT_FOLDER_ID",
    data=FolderCreateParamsData(
        name="Folder name",
    ),
)

As for file uploads, with V4 there are two methods available, remote and local. Below are examples for each.

Remote upload:


from frameio import Frameio
from frameio.files import FileCreateRemoteUploadParamsData

client = Frameio(
    token="YOUR_TOKEN",
)
client.files.create_remote_upload(
    account_id="YOUR_ACCOUNT_ID",
    folder_id="ROOT_FOLDER_ID",
    data=FileCreateRemoteUploadParamsData(
        name="new_file.png",
        source_url="SOURCE_URL",
    ),
)

Local upload:


from frameio import Frameio
from frameio.files import FileCreateLocalUploadParamsData

client = Frameio(
    token="YOUR_TOKEN",
)
client.files.create_local_upload(
    account_id="ACCOUNT_ID",
    folder_id="ROOT_FOLDER_ID",
    data=FileCreateLocalUploadParamsData(
        file_size=1137444,
        name="asset.png",
    ),
)

Here is a guide on uploading that may help as well: How to Upload | Frame.io API Documentation

I hope this helps!

hi @piroP you would want to use the Frame.io python available on pypi (pip install frameio) and see our reference guide here: Python SDK Reference | Frame.io API Documentation

For create folder, you would use the following via sdk:

from frameio import Frameio
from frameio.folders import FolderCreateParamsData

client = Frameio(
    token="YOUR_TOKEN_HERE",
)

client.folders.create(
    account_id="69fd1f97-4291-430d-84f0-29fcaf6fd0bf",
    folder_id="05e48f0b-a372-4b3a-bf5b-3fa4082275f8",
    data=FolderCreateParamsData(
        name="Folder name",
    ),
)

You will need to set up and create your own authentication via IMS to fetch an auth token and exchange for an access token, you can learn more about that here (I also have an update coming soon for the python sdk to help tackle this!)

The uploader function doesn’t exist yet in the SDK, that’s coming soon, but for now you would use our How to Upload guide via Local Upload to upload your file. Example pseudo code is in the guide.

Please let us know if you run into any issues!

Rosie beat me to it! :smiley:

hi @piroP we just released our auth sdk for python, you can find more information here: