Download Component
2 2

3 posts in this topic

Hi Toke,

If you just want to download it, you can get the URL from the server location by calling get_url:

server_location = session.query('Location where name is "ftrack.server"').first()
url = server_location.get_url(component)

# Use requests module or something else to download the file.

 

Share this post


Link to post
Share on other sites

Hey Mattias,

Thanks, works:)

Modified the code from this nice thread: https://stackoverflow.com/questions/16694907/how-to-download-large-file-in-python-with-requests-py

 

def download_file(url, path):
    r = requests.get(url, stream=True)
    with open(path, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024): 
            if chunk:
                f.write(chunk)
    if os.path.exists(path):
        return True
    else:
        return False

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
2 2