Salesforce Meets Dropbox: How to Upload and Access Files with Ease


NSIQ Icon
July 17, 2025

salesforce meets dropbox upload and access files with ease

Introduction

Salesforce is a powerful CRM platform, but its native file storage capabilities can be limited for businesses handling large volumes of documents. Integrating Dropbox with Salesforce provides a seamless solution for managing and sharing files efficiently. This blog will guide you through the benefits, integration methods, and steps to connect Dropbox with Salesforce.

If you’re exploring Salesforce CRM Integration Services, integrating cloud storage like Dropbox is a valuable option to streamline document workflows and enhance productivity.

Implementation Details:

1. Authentication and Setup: 

  • To begin, a Dropbox account is required for integration. If you don’t have a Dropbox account, you can register at https://www.dropbox.com
  • Go to Dropbox Developer and create a new app.
  • Select “Scoped Access” and choose the appropriate permissions.
  • Generate an OAuth access token for authentication.

SDFC integration 2

2. Custom Lightning Web Component (LWC):

  • Create an LWC component to allow users to upload files directly from Salesforce to Dropbox.
  • Display uploaded files as links in Salesforce records

Global Sourcing

3. Set Up an Apex Class to Handle API Calls:

  • Use HttpRequest to connect with Dropbox API for file uploads and creating shared links.
  • Store Dropbox file links in Salesforce records.

Apex Code for Uploading file in Dropbox:

@AuraEnabled
public static String uploadFile(String fileName, String fileBody) {
String dropboxApiUrl = ‘https://content.dropboxapi.com/2/files/upload’;
String dropboxPath = ‘/’+ fileName;
HttpRequest req = new HttpRequest();
req.setEndpoint(dropboxApiUrl);
req.setMethod(‘POST’);
req.setHeader(‘Authorization’, ‘Bearer ‘ + DROPBOX_ACCESS_TOKEN);
req.setHeader(‘Content-Type’, ‘application/octet-stream’);
req.setHeader(‘Dropbox-API-Arg’, ‘{“path”: “‘ + dropboxPath + ‘”, “mode”: “add”, “autorename”: true, “mute”: false}’);
Blob fileBlob = EncodingUtil.base64Decode(fileBody);
req.setBodyAsBlob(fileBlob);
Http http = new Http();
HTTPResponse res = http.send(req);
if (res.getStatusCode() == 200) {
return ‘File uploaded successfully!’;
} else {
throw new AuraHandledException(‘Dropbox Upload Failed: ‘ + res.getBody());
}
}

Apex Code for Creating Shared Links in Dropbox:

@AuraEnabled
public static Map<String, String> getDropboxFileLink(String fileName) {
Map<String, String> result = new Map<String, String>();
try {
String url = ‘https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings’;
String previewFile = ‘/’ + fileName;
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint(url);
request.setMethod(‘POST’);
request.setHeader(‘Authorization’, ‘Bearer ‘ + DROPBOX_ACCESS_TOKEN);
request.setHeader(‘Content-Type’, ‘application/json’);
request.setBody(‘{“path”: “‘ + previewFile + ‘”, “settings”: {“requested_visibility”: “public”}}’);

HttpResponse response = http.send(request);
if (response.getStatusCode() == 200) {
Map<String, Object> jsonResponse = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
String previewUrl = ((String) jsonResponse.get(‘url’)).replace(‘?dl=0’, ‘?raw=1’);

// Return result directly as a Map
result.put(‘previewUrl’, previewUrl);
result.put(‘name’, fileName);
return result;
} else {
System.debug(‘Dropbox API Error: ‘ + response.getBody());
return null;
}
} catch (Exception e) {
System.debug(‘Error fetching Dropbox permanent link: ‘ + e.getMessage());
return null;
}
}

Conclusion

Integrating Dropbox with Salesforce enhances file management by offering scalable storage, better collaboration, and seamless access to documents. Whether using the official AppExchange app or a custom API integration, Dropbox provides a secure and efficient way to handle Salesforce files.

By following the steps outlined in this blog, you can ensure a smooth Dropbox-Salesforce integration tailored to your business needs.