Is it possible to copy the entire Dropbox drive to local machine by Python? The available code copy a specific folder and not the entire drive.
Asked
Active
Viewed 71 times
0
-
What available code? – KamilCuk Aug 31 '18 at 23:35
-
Examples on the Internet let you copy a single folder or file to local machine, but not the entire drive. – Anmar Aug 31 '18 at 23:47
-
What examples? Where are they? Can't you post links? – KamilCuk Sep 01 '18 at 00:02
-
Visit this link please. [ https://stackoverflow.com/questions/51069637/file-migration-via-dropbox-api ] similar idea. – Anmar Sep 01 '18 at 00:15
-
Och, so you are using a [dropbox api](https://www.dropbox.com/developers/documentation/python). – KamilCuk Sep 01 '18 at 00:17
-
The dropbox api has a [list_folder](https://github.com/dropbox/dropbox-sdk-python/blob/master/example/updown.py#L125) function, have you tried that. – KamilCuk Sep 01 '18 at 00:19
-
Seems like this https://stackoverflow.com/questions/42085972/how-to-list-all-files-and-folders-in-my-dropbox-using-v2-api can list all folders inside a dropbox, just post `"/"` to the `files_list_folder` function – KamilCuk Sep 01 '18 at 00:21
-
Kamil Cuk, thank you for the response. I will try it and post an update. – Anmar Sep 01 '18 at 21:07
1 Answers
0
list_folder function worked like a charm!. Thank you a lot Kamil Cuk. Here is the code may it will help someone:
import requests
import json
url = "https://api.dropboxapi.com/2/files/list_folder"
headers = {
"Authorization": "Bearer INSERT YOUR ACCESS TOKEN HERE",
"Content-Type": "application/json"
}
data = {
"path": ""
}
r = requests.post(url, headers=headers, data=json.dumps(data))

Anmar
- 67
- 1
- 10
-
After list contents of the Dropbox drive,it's easy to copy it to local machine now. – Anmar Sep 01 '18 at 23:27
-
By the way, you're not guaranteed to get all of the results from a single call to [/2/files/list_folder](https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder). You need to check the `has_more` value, and call back to [/2/files/list_folder/continue](https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-continue) if it's `true`, and so on. Refer to the [/2/files/list_folder](https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder) documentation for more information. – Greg Sep 04 '18 at 15:44