One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
yarnthen
8 years agoExplorer | Level 3
SwiftyDropbox listfolder result for pathDisplay showing results in small caps
Hi,
Was trying to do a listing of files and folders in a path /My Pictures. But I noticed that the result returned are in small caps if the return value is for a file will be of small caps but the return value for a folder will be of original case. Am I using the wrong function to get the folder and files path as it is not accurate(incorrect case). The sample output is after the code below
if let client = DropboxClientsManager.authorizedClient{ // List contents of app folder client.files.listFolder(path: "/My Pictures", recursive: true, includeMediaInfo: true, includeDeleted: false, includeHasExplicitSharedMembers: false, includeMountedFolders: false, limit: nil, sharedLink: nil).response(completionHandler: { (response, error) in if let result = response { for entry in result.entries{ if !(entry is Files.FileMetadata){ print("folder path is \(entry.pathDisplay!)") }else{ print("file path is \(entry.pathDisplay!)")
} } } }) }
Output:
folder path is /My Pictures
folder path is /My Pictures/April 2013
file path is /my pictures/April 2013/IMG_5145.JPG
file path is /my pictures/April 2013/IMG_5152.JPG
file path is /my pictures/April 2013/IMG_5081.JPG
file path is /my pictures/April 2013/IMG_5084.JPG
file path is /my pictures/April 2013/IMG_5148.JPG
file path is /my pictures/April 2013/IMG_5083.JPG
file path is /my pictures/April 2013/IMG_5146.JPG
file path is /my pictures/April 2013/IMG_5122.JPG
file path is /my pictures/April 2013/IMG_5149.JPG
file path is /my pictures/April 2013/IMG_5107.JPG
file path is /my pictures/April 2013/IMG_5108.JPG
file path is /my pictures/April 2013/IMG_5085.JPG
file path is /my pictures/April 2013/IMAG0101.jpg
file path is /my pictures/April 2013/IMG_5079.JPG
file path is /my pictures/April 2013/IMG_5106.JPG
- Greg-DB
Dropbox Staff
You're not doing anything wrong. Dropbox is case-insensitive, and attempts to be case-preserving, but sometimes you won't see the original expected case. You should use pathLower when performing operations, as that's the canonicalized version of the path. You should use pathDisplay for display purposes, where the case will be preserved to the extent possible. Even in pathDisplay though, the original casing isn't always available. There's a note about this in the API v2 documentation, under "Case insensitivity":
"Also, while Dropbox is case-insensitive, it makes efforts to be case-preserving. Metadata.name will contain the correct case. Metadata.path_display usually will contain the correct case, but sometimes only in the last path component. If your app needs the correct case for all components, it can get it from the Metadata.name or last path component of each relevant Metadata.path_display entry."
There's also some information in the documentation for Metadata.pathDisplay. Metadata.name will contain the case-preserved name, so the workaround would be to build the path up from each of those.We understand this is non-ideal of course, and I'll forward this on to the team as feedback, but I can't make any promises as to if or when this might be improved in the future.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 2 hours ago
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!