How to use Dropbox API as files source for Comparison API
How to use Dropbox API as files source for Comparison API
Leave feedback
On this page
Nowadays Cloud services are highly popular. Therefore, lots of people use them as a storage for photos, images, documents and other files. This way, you may need opportunity to compare documents directly from Dropbox, without downloading and saving them locally. You can do it easily using GroupDocs.Comparison API together with Dropbox API.
Configuring Dropbox API
Preparing to using Dropbox API you must have Dropbox account. It is very easy to register one. You can find out required steps on Dropbox documentation page. Still, below are steps, which you need to do before using Dropbox API.
Then choose App folder (you can choose Full dropbox to give app access to all your files)
Finally, enter app name and click Create app
Updating Dropbox API settings
First of all, open Permissions tab and select next permissions
files.metadata.write
files.metadata.read
files.content.write
files.content.read
Do not forget to click Submit button to save changes
After saving changes go back to Settings tab and generate access token clicking Generate button
Keep in mind that after any changes of permissions you must generate new token, old one will not automatically updated according to permissions changes
That’s actually all. The token is the only thing that you need to access your Dropbox files. Save the token somewhere, we will use it later.
Configuring project to use Dropbox API with Comparison API
To use Dropbox API as a file storage for comparing documents, you need to add some libraries and repository to the project.
Connect GroupDocs repository
MavenGradleKotlin
Libraries
MavenGradleKotlin
Creating Dropbox API objects
Actually, it is very easy to start working with Dropbox API
Where:
mycompany/best-comparison-app - is just identifier that you will see in logs of Dropbox website
YOUR ACCESS TOKEN - here should be access token, that was generated previously
Get list of files using Dropbox API
To print list of files which are in your Dropbox app directory, run next code (do not forget to upload some files via Dropbox webpage, because by default app directory is empty)
In the output each line is one file. It’s path, name and size. You can use this information to show list of files. There are more data, that can be got for each file. More information can be found on Dropbox Documentation page. Keep in mind, the code above is just example. There is a pagination, that should be processed in order to get all files.
Comparing documents directly from Dropbox
GroupDocs.Comparison for Java is a flexible, powerful and modern library that you can use in any Java, Kotlin or other Java compatible projects to compare Word, Excel, PowerPoint documents, photos, images, diagrams, code files, and much more supported file formats. Comparison API contains lots of flexible settings, for example: accepting/rejecting changes, generating summary page, generating document preview images, comparing more than two documents (multi comparing), changing comparison sensitivity and changes highlighting styles. Read more about settings in the documentation. On our GitHub page you can find different samples of using Comparison library with different frameworks, as Dropwizard, Spring, Kotlin Compose Desktop and so on.
Saving the result Document on local disk
It is easy compare dwo documents from on your Dropbox saving the result document on local disk or writing it into Java output stream to use it wherever you want.
In output console you will see path to the result document.
Saving the result Document into Dropbox
Below you can see, how to compare documents directly from Dropbox with uploading the result document into Dropbox without saving it locally. After that, you can open Dropbox in web browser and find the result document.
In output console you will see path of the uploaded document.
Get a Free API License
Most of the settings, for example generating summary page, sensitivity of comparison and so on are available only with license. You can get a free temporary license in order to use the API without evaluation limitations.
Conclusion
In this article was shown the way to use Dropbox API as a source of documents for GroupDocs.Comparison library that you can use in your own project. There are samples of using Dropbox API inside Spring and Dropwizard applications on GitHub page. They are available for modification and using as a core of your own application for comparing photos, Excel, Word, code files, PowerPoint Presentations and other supported file formats.
For more details, options, and examples, you can go through the documentation and GitHub repository. Reach us on the forum for your queries.