Using Dropbox APIs, I am able to get view of all the folders in the root folder and using metadata, I can print all the information from JSON on the screen.
For example, a sample output would be like
{
'bytes': 0,
'contents': [
{
'bytes': 0,
'icon': 'folder',
'is_dir': True,
'modified': 'Thu, 25 Aug 2011 00:03:15 +0000',
'path': '/Sample Folder',
'rev': '803beb471',
'revision': 8,
'root': 'dropbox',
'size': '0 bytes',
'thumb_exists': False
},
{
'bytes': 77,
'icon': 'page_white_text',
'is_dir': False,
'mime_type': 'text/plain',
'modified': 'Wed, 20 Jul 2011 22:04:50 +0000',
'path': '/magnum-opus.txt',
'rev': '362e2029684fe',
'revision': 221922,
'root': 'dropbox',
'size': '77 bytes',
'thumb_exists': False
}
],
'hash': 'efdac89c4da886a9cece1927e6c22977',
'icon': 'folder',
'is_dir': True,
'path': '/',
'root': 'app_folder',
'size': '0 bytes',
'thumb_exists': False
}
I am not sure, how can I get elements of 'contents' array and then recursively, get files using 'path' attribute.
And my ultimate goal is to get list of all files in Dropbox
folder. Is there any better way to get list of all files?
I have tried following code:
folder_metadata = self.api_client.metadata('/Photos')
print "-----------------------------"
print "path:", folder_metadata['path']
for s in folder_metadata['contents']:
for dirname, dirnames, filenames in os.walk(s['path']):
for filename in filenames:
var = os.path.join(dirname, filename)
print var
and its output is:
-----------------------------
path: /Photos
How can I get an absolute path?