DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Beyond Extensions: Architectural Deep-Dives into File Upload Security
  • The Real-time Data Transfer Magic of Doris Kafka Connector's "Data Package": Part 1
  • Designing a Java Connector for Software Integrations
  • Dynamic File Upload Component in Salesforce LWC

Trending

  • The Twelve-Factor Agents: Building Production-Ready LLM Applications
  • Observability Fundamentals Beyond Traditional Monitoring
  • AI and Agentic: Promise, Peril, and Predictability
  • Jeffrey Microscope for Generating Flame Graphs in Java

Mule 4 Dropbox Connector To Upload File on Dropbox

This tutorial will teach you the steps to upload files on Dropbox and also to get a list of files/folders using Mule 4 Dropbox Connector.

By 
Dhawnit Thadhani user avatar
Dhawnit Thadhani
·
Updated Apr. 28, 21 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
10.0K Views

Join the DZone community and get the full member experience.

Join For Free

Step 1

Create a Dropbox account or sign in using an existing account.

Dropbox Login/Signup page

Step 2

Once you have created your account on Dropbox, create an app on Dropbox. Click on this URL to create an app.

Step 3

Click on Create app.

Create app

Step 4

Provide the below details to create your app:

  •  Choose an API: Scoped Access.
  •  Select Full Dropbox Access to all files and folders in a user’s Dropbox under the type of access.
  •  Name your app, e.g., MulesoftAPI.
  •  Click on Create app. Your app will be created successfully.

Highlighted portions to fill in app creation

Step 5

Now click on the permissions tab to give the required permissions to our App.

As we are going to upload files on Dropbox and also to get a list of files/folders, we need certain permissions to access. so kindly give below required permissions:

  1. files.content.write
  2. files.content.read
  3. file_requests.write
  4. file_requests.read

Submit After Giving Conditions

Click on submit after giving permissions.

Set PermissionsSet Permissions.

Note: For other operations of Dropbox connector like download files, Create, Search, etc. we have to provide required permissions to our app.

Step 6

The next step is to generate an access token for our app that will be used in the Mule application for configuring Dropbox connector.

Under the Settings tab, click on generate access token [oauth2].

Access Token

Access Token.

Copy the access token to use further in the Mule Application. Based on your requirements you can select Access Token Expirations as Short-Lived or No Expiration. By default access token expiration is Short-Lived.

Step 7

Now Dropbox Setup is completed, Time to create a Mulesoft Dropbox application for Uploading File.

  1. Create Project in Anypoint Studio.
  2. Go to Mule palette and add Dropbox Connector by searching Dropbox connector in Exchange.
  3. Dependency will be added.

Add Dropbox Connector

Add Dropbox Connector.

Step 8

Configure the Listener/Scheduler/New or Update File Connector to trigger the request. I am using an HTTP listener to trigger the request and then adding a Read File connector to read files from a specific path.   

Input File Path: /src/main/resources/input.json

Input and File Path

Input and File Path.

Step 9

Add transform the message to transform the JSON payload to CSV.

Output Payload

Step 10

Drag and drop the "Files: Upload File" dropbox connector operation from the Mule palette and configure the connection by providing the access token generated above and the app name which we created in Dropbox.

Dropbox Connector Configuration

Dropbox Connector Configuration.

Step 11

After configuring the dropbox connector, configure the path and file content of the Upload File operation.

Provide the File Content as payload and path as /Mulesoft/demo.csv.

Note: It will create a Mulesoft folder in Dropbox and the file will be uploaded under the Mulesoft folder

Upload File Operation

Step 12

Drag and Drop Set Payload after Files: Upload File operation to give response as 'Congrats, File Uploaded Successfully in Dropbox.'

File Uploaded Successfully in Dropbox!

Step 13

Deploy Mule Dropbox project and trigger request via Postman.

Mule App Deployment

Mule App Deployment.

Success Response

Success Response.

Congratulations, you just uploaded the file on Dropbox!

Step 14

To check whether the file is uploaded on Dropbox, just log in to your Dropbox account and we can see the Mulesoft folder is created.

Under the Mulesoft folder, we can see that the demo.csv file is uploaded.Dropbox > Mulesoft > demo.csv

demo.csv file output:

File Uploaded-demo.csv

File Uploaded-demo.csv.

Step 15

Similarly, If you want to get a list of files or folders present in the Dropbox folder, You can use the File: List folder operation of the Dropbox connector.

  • Create another flow then configure listener to trigger request, once the listener is configured then drag and drop File: list folder operation of Dropbox Connector.
  • Give the path as /Mulesoft under File: List Folder operation and it will retrieve all files/folders present in that folder.
  • After configuring connector, We need to retrieve files or folder name from the  response so we have placed the Transform message component at the end of the flow in the message processor to transform the payload into a JSON message.              Files: List Folder Configuration
Files: List folder configuration.

Transform Message

Transform Message.

Step 16

I have added one Book.xlsx file in Dropbox Mulesoft Folder so that we can get the list of files from that folder.

Book.xls Added to Dropbox FolderNow deploy the project and trigger the request via Postman. Below, Postman's response also shows two files present in Mulesoft Folder.

Postman's Response Showing 2 Files

Conclusion

This is how you can use Mulesoft Dropbox Connector to upload files, get list of files/folder. Similarly there are other operations of Mule 4 Dropbox connector like Create Folder, Delete, Move, Download, Search, Get Metadata etc. You just need to set/have proper permissions for same like we set for Upload file and File: List Folder.

Happy Learning!!!

Dropbox (service) Connector (mathematics) Upload

Opinions expressed by DZone contributors are their own.

Related

  • Beyond Extensions: Architectural Deep-Dives into File Upload Security
  • The Real-time Data Transfer Magic of Doris Kafka Connector's "Data Package": Part 1
  • Designing a Java Connector for Software Integrations
  • Dynamic File Upload Component in Salesforce LWC

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook