cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

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

I am having trouble using with_path_root() with python

I am having trouble using with_path_root() with python

jdavey
Explorer | Level 3

I have an container-based AWS Lambda that reads from S3 and writes to Dropbox.  It has worked for months and it quit working on Saturday (2023-11-17) morning.

 

Given two folders and paths

  • My Team/folder01/folder02
  • Some User  # person that created the token

using python, when I call 

files_upload(b'data', 'My Team/folder01/folder02/filename.txt')

to write a file:

1. it used to write the file: `My Team/folder01/folder02/filename.txt`

2. now it writes the file: `Some User/My Team/folder01/folder02/filename.txt`

 
After much reading, I have discovered that I need to set the path root for the "team" rather than the "member" or user.

 

I am now doing that with the following two lines:

root_namespace_id = dbx.users_get_current_account().root_info.root_namespace_id
dbx = dbx.with_path_root(dropbox.common.PathRoot.root(root_namespace_id))

this works great locally on my development computer, but when I add the two lines to my AWS Lambda logic, it appears to be ignored when I execute it remotely.

 

Given the following four lines:

dbx = DropboxTeam(DROPBOX_ACCESS_TOKEN).as_user(DROPBOX_TEAM_USER)
root_namespace_id = dbx.users_get_current_account().root_info.root_namespace_id
dbx = dbx.with_path_root(dropbox.common.PathRoot.root(root_namespace_id))
metadata = dbx.files_upload(b'data', 'My Team/folder01/folder02/filename.txt')

 

If I execute those four lines on my local computer the files write to the expected (team) folder

My Team/folder01/folder02/filename.txt

 

If my AWS Lambda executes those four lines, it writes to the user/member folder 

Some User/My Team/folder01/folder02/filename.txt

 

I have logged out the 

root_namespace_id

 it is the same, both locally and remotely

 

The only thing I see in the metadata is that 

Locally:

  • parent_shared_folder_id='12345678'
  • sharing_info=FileSharingInfo(modified_by=...)

Remotely: 

  • parent_shared_folder_id=NOT_SET
  • sharing_info=NOT_SET 

Do I need to do something special when making this call in an AWS Lambda?  

1 Reply 1

DB-Des
Dropbox Engineer

Hello,

 

There is nothing special, or different, that needs to be done when running code in AWS Lambda from the Dropbox side. If it's working locally (in dev), it should work remotely (on a server). Are you able to re-confirm that the same exact code is being run in both environments?

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    DB-Des Dropbox Engineer
What do Dropbox user levels mean?