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: 

How to display folders in the file list Dropbox API (Swift 5)

How to display folders in the file list Dropbox API (Swift 5)

VyacheslavB
Helpful | Level 5
Go to solution

I get a list of the user's files and then filter it to show only the music files. But I also want to see subfolders. How should I set up my filter for this? Could you help me.
My function where I get the list of files looks like this:Screen Shot 2020-08-25 at 12.03.28.png

I also want to be able to enter a subfolder, as I understand it, for this I need to insert the path to the subfolder in path: "/ someFolder". But how can I get this path?

11 Replies 11

Greg-DB
Dropbox Staff
Go to solution

@roggerCorrea It looks like fileList would be an array, perhaps initialized like 'var fileList = [Any]()', or maybe more ideally 'var fileList = [Files.Metadata]()'.

 

Your cast is failing because you're attempting to cast the entire array of Metadata, that is, your 'response', which is the listFolderResult?.entries, instead of individual Metadata entries.

 

You should instead first iterate over the entries to get each entry, like the 'for entry in result.entries {' line in the original post shows.

roggerCorrea
Explorer | Level 3
Go to solution

Hi Greg, thank you so much. I'm new to Swift and still figuring out many things. 

 

This was of great help!

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    roggerCorrea Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Mimi_89 New member | Level 2
What do Dropbox user levels mean?