cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get size and date of file

Get size and date of file

denickman
Explorer | Level 4
Go to solution

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!

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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!)
   }
}

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

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!)
   }
}

denickman
Explorer | Level 4
Go to solution

Thank you very much!!!

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    denickman Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?