cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Check out the Dropbox cheat sheet for getting started in 2021 here!

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Write File to Team location - Python API

Write File to Team location - Python API

New member | Level 2

Hi,

I have a simple python script to write a file to Dropbox. The issue I'm having is this only seems to give me access to my user area and I need to write the file to the team area. I have read  documentation but am struggling to find any simple examples using the python API.

Thanks

Matt

import dropbox

access_token = '*************************************'

file_from = 'test.txt'
file_to = '/test_dropbox/test.txt'

dbx = dropbox.Dropbox(access_token)

with open(file_from, 'rb') as f:
    dbx.files_upload(f.read(), file_to)

 

1 Reply 1

Re: Write File to Team location - Python API

Dropboxer

It sounds like your team is using the "team space" configuration. You can access the team space via the API. To do so, you'll need to use the namespace IDs to specify which area you want to access. I recommend reading the Namespace Guide, which covers this in detail:

https:confused face:/www.dropbox.com/developers/reference/namespace-guide 

In the Python SDK in particular, to specify a particular root, you should use `with_path_root`. For example:

dbx.with_path_root(dropbox.common.PathRoot.root("XXXXXXXXX")).files_list_folder("")

or:

dbx.with_path_root(dropbox.common.PathRoot.namespace_id("XXXXXXXXX")).files_list_folder("")

 

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?