cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Discuss Dropbox Developer & API

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

dropbox Api in js

dropbox Api in js

IgorTsivan
Explorer | Level 4
Go to solution

Hi, help me pls. 

I can’t understand the API how to navigate folders and files in my application if I have already displayed the top level of folders and files on the screen. I work with React.js

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

You can download the file data using the API/SDK. Please refer to my comment here for some information on doing that.

Exactly what you do with the data, e.g., how you display or present it to the user, will depend on your use case.

View solution in original post

8 Replies 8

Greg-DB
Dropbox Staff
Go to solution

Can you elaborate on what exactly you're currently stuck on?

To use the Dropbox API from JavaScript, we recommend using the official Dropbox API v2 JavaScript SDK.

With that, you can use the filesListFolder and filesListFolderContinue methods to list the contents of any desired folder, at any level, by passing the full path of the desired folder to filesListFolder

IgorTsivan
Explorer | Level 4
Go to solution

Thanks for the answer. I am a junior developer and try to understand how to use these methods exactly. The photo shows how I use the filesListFolder method. And I want to clarify how I can move on so that I can navigate folders and open files in my application? I understand that the list_folder / continue method is needed, but how to use it?

I tried to solve this problem for a very long time, and I will be grateful for the help. If necessary, I can attach the entire code. Thanks:)

dbx.pngdbx-app.png

Greg-DB
Dropbox Staff
Go to solution

When you get the response from filesListFolder you need to check the returned FilesListFolderResult.has_more value and if it's true, call back to filesListFolderContinue. Calling filesListFolderContinue works the same way as filesListFolder except that you pass in a 'cursor', from FilesListFolderResult.cursor. It also returns the same FilesListFolderResult type.

To download a file, use the filesDownload and pass in the 'path_lower' for the desired file. Here's an example showing how to access the file data. (It's written for sharingGetSharedLinkFile but it works the same way.)

By the way, you posted your access token in your screenshot. I replaced your screenshot with a redacted version, but for the sake of security, you should disable that access token since it was posted publicly. You can do so by revoking access to the app entirely, if the access token is for your account, here. Or, you can disable just this access token using the API, via HTTP, or JavaScript SDK.

IgorTsivan
Explorer | Level 4
Go to solution

Good, I got it, thanks 🙂

If the return value of FilesListFolderResult.has_more is false, since the entire filelist folder is loaded.bdx-2.png

But I need to click on a folder to open its contents, which is one level lower. I read that methods are needed here (filesMoveBatchV2, filesMoveBatchCheckV2). And so I don’t quite understand how they work and how I can implement this. didn't see anything like it on the internet 😞

Greg-DB
Dropbox Staff
Go to solution

The "move" methods would only be if you need to actually change the location of a file or folder in the Dropbox account.

If you just want to browse a different folder, you can call filesListFolder/filesListFolderContinue again, supplying the 'path_lower' of the sub-folder you want to list. You would then use the result from that to update your UI to show that listing.

IgorTsivan
Explorer | Level 4
Go to solution

Thanks! helped) last question, can I open files for viewing in my application?

Greg-DB
Dropbox Staff
Go to solution

You can download the file data using the API/SDK. Please refer to my comment here for some information on doing that.

Exactly what you do with the data, e.g., how you display or present it to the user, will depend on your use case.

IgorTsivan
Explorer | Level 4
Go to solution

Thanks!

Need more support?
Who's talking

Top contributors to this post

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