0

python 3.8

I've a Dropbox account which is sharing some folders from another Dropbox user. I can see and download these shared folders manually . But there are thousands of folders.

I've created a Dropbox app so have a Oauth2 api_key and api_secret. Once logged in I'm trying to follow these instructions

https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_folders

with my generated api_token

Executing the generated python snippit

headers = "{'Authorization':"Bearer fffooobbbaaarrr", 'Content-Type':"application/json"}
data = {}
url = "https://api.dropboxapi.com/2/sharing/list_folders"
r = requests.post( url, headers=headers, data=json.dumps(data))
dicct = json.loads(r.content)

yields a nested dictionaries of entries, each of which has a "path_lower" attribute. So how do I drill down through these to discover, say, "{'path':"/eric/iphone/Messages"} and then download_zip every subdir under /e/i/M ?

TIA,

Still-Learning Steve

1 Answer 1

0

Scrolling around the documentation link you provided, I found a /download_zip endpoint.

But before writing requests manually, Dropbox actually has a Python SDK with a nice Getting Started page that also supports the Download Zip endpoint.

What I would do (if I had a dropbox account) is to start a new venv that is isolated from your system Python. Activate (select) the venv by running the activate script, and pip install dropbox on there and run some experiments.

It's also easily removable, at least for the Python-default venv kind, because the activate script only changes PATH variables for the current shell.

I don't have anything to download on my Dropbox account so I didn't spin anything up yet. Maybe I'll come back and edit this answer with a working example when I get more time. Leave a comment if you're still stuck. Good luck!

Sign up to request clarification or add additional context in comments.

1 Comment

download_zip was what I planned to use on each of the 1000s of folders once I found them. found using /2/files/search_v2 against the 2nd-lowest level of folder did the trick in my specific case. Had I a more modern python I could use the dropbox module ( dbx-style) and would have been spared all the https calls. No longer stuck - thx for the reply!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.