Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hello guys. Please give me your advise. I use Swift Dropbox API request (client.files.listFolder) for getting all folders/files recursively. In response I get description for every entry such as:
Description: {
"client_modified" = "2015-10-12T16:35:08Z";
"content_hash" = ca84996436ae8c430930029ed076c737fadc636556edc6cbbbe30a2d37a4c29e;
id = "id:hpY6wdEzzkAAAAAAAAAADg";
"is_downloadable" = 1;
name = "2601130556_1154272064.jpg";
"path_display" = "/folderOne/2601130556_1154272064.jpg";
"path_lower" = "/folderone/2601130556_1154272064.jpg";
rev = d3e1412dd;
"server_modified" = "2015-10-12T16:35:08Z";
size = 886663;
}
so the problem that descriptions has already been serialized from
open var description: String {
return "\(SerializeUtil.prepareJSONForSerialization(ListFolderResultSerializer().serialize(self)))"
}
}
The question is how can I get (serialize) size and client_modified date from this if it is a string-value already? Please help me!
You can access fields like size, etc., via the fields on the FileMetadata type, like this:
client.files.listFolder(path: path).response { (result, error) in if let listing = result { for entry in listing.entries { switch entry { case let fileMetadata as Files.FileMetadata: print("File name: \(fileMetadata.name)") print("File size: \(fileMetadata.size)") print("File server modified time: \(fileMetadata.serverModified)") print("File client modified time: \(fileMetadata.serverModified)") default: print("other") } } // check listing.hasMore to see if there are more entries to retrieve } else { print(error!) } }
You can access fields like size, etc., via the fields on the FileMetadata type, like this:
client.files.listFolder(path: path).response { (result, error) in if let listing = result { for entry in listing.entries { switch entry { case let fileMetadata as Files.FileMetadata: print("File name: \(fileMetadata.name)") print("File size: \(fileMetadata.size)") print("File server modified time: \(fileMetadata.serverModified)") print("File client modified time: \(fileMetadata.serverModified)") default: print("other") } } // check listing.hasMore to see if there are more entries to retrieve } else { print(error!) } }
Thank you very much!!!
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!