I hope you now have a clear idea about how to access files from Dropbox and use them in a Xamarin application. Step 5: You could also save the file to a specific folder by providing the file name in this format: folder name/file name (e.g., Syncfusion/PDF_Succinctly2.pdf). Entering a file name (e.g., PDF_Succinctly.pdf) and clicking OK will save the document in the Dropbox. Step 4: Once Save is clicked, a pop-up view to obtain the file name will be displayed. Also, you can save them to the signed-in Dropbox account by clicking on the save option.
Step 3: Then, you can edit the PDF file loaded using the options in the PDF Viewer control. You can also select another file by clicking on the** Files** option in the top grid section. You can select any PDF file from the list to view it in the PDF Viewer control. Step 2: After entering your credentials, the list of PDF files from the user’s Dropbox account will be displayed in a pop-up list view. Step 1: In this sample, initially a Dropbox login interface will be displayed for your Dropbox credentials. The following steps describe the procedures involved in working with this sample project. You can find the sample project of loading and saving Dropbox PDF files using Syncfusion Xamarin PDF Viewer in this GitHub location. Step 8: Similarly, you can call the WriteFile( MemoryStream fileContent, string fileName) method to write or save the modified PDF back in the Dropbox. Then, assign the converted stream to the PdfDocumentStream property in the DropboxViewModel class. Step 7: To view the PDF file in Dropbox in our Syncfusion Xamarin PDF Viewer, call the ReadFile( string fileName) method and convert the resultant byte array to stream. / Upon completion is called /// /// An asynchronous task. Private const string ClientId = "Your App secret key" private const string RedirectUri = "Your Redirect Uri" /// /// Runs the Dropbox OAuth authorization process if not yet authenticated. The ClientId (App secret) and RedirectUri values can be obtained from the Dropbox developers site/console. In its navigation event, add the logic to obtain the Dropbox access token once when the authentication is completed. Here, we use Webview to display the login interface. Step 4: Create a class named DropboxService and add all the logic to establish the connection and obtain the information from the Dropbox. Then bind the InputFileStream property of SfPdfViewer to the PdfDocumentStream property. Then, in the MainPage.xaml, set the binding context as DropboxViewModel and add the SfPdfViewer control. Add a binding property PdfDocumentStream of type Stream in the ViewModel class. Step 3: Create a ViewModel class and name it DropboxViewModel.
Step 2: Install the packages Dropbox.Api in the PCL project and in all the projects. Step 1: Create a new Xamarin.Forms project. Please follow these steps to establish the connection, access PDF files in the Dropbox, and view them using our Syncfusion Xamarin PDF Viewer. For more details, please refer to this tutorial.īut in our Xamarin application, we are going to generate the access token programmatically to manage the Dropbox files.Īccess Dropbox files and use them in a Xamarin application Use the Dropbox API class DropboxClient to establish the connection and manage the files. So, you should copy this token and use it in the client application to establish the connection. You need to use this App secret key information to generate an OAuth2 access token.įor a simple C# console application, you can directly generate the access tokens from the developer site and use them in your program. Step 5: Then, the following page will be displayed with the application settings information in it. Step 4: Finally, provide a name for your application and click Create app. You can restrict the access to the application to a specific folder or allow access to all the folders.
The suggested option is to use the free Dropbox API. Step 2: Next, select the type of API you want to use with your application.
For that, navigate to the Dropbox developers site and click Create Apps. Step 1: To start with, you need to register your application in the Dropbox platform. In this blog, we will walk you through the steps to access files in Dropbox and use them in a Xamarin.Forms application, with an example of accessing a PDF file and displaying it in our Syncfusion Xamarin PDF Viewer. However, at some point, we all have found it hard to access files available in the Dropbox and use them in our Xamarin applications. We all know that Dropbox is one of the most popular file-hosting services for the cloud.