We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
denickman
6 years agoExplorer | Level 4
Get size and date of file
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!) } }
2 Replies
- Greg-DB6 years ago
Dropbox Community Moderator
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!) } }
- denickman6 years agoExplorer | Level 4
Thank you very much!!!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,037 PostsLatest Activity: 29 minutes ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or 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!