Skip to main content

File Upload

Explore practical guides and implementation patterns for this topic.

Posts

Topic LWC
Lightning Web Components

File Upload in LWC: lightning-file-upload, ContentDocument & Best Practices

In plain words: The <lightning-file-upload> component is a native Salesforce LWC tool that lets users drag and drop or browse files directly from their computer into Salesforce. It automatically handles chunked file uploads, converts files into ContentVersion / ContentDocument records, and links them directly to the active record ID without requiring custom Apex upload endpoints or hitting the 6 MB synchronous heap size limit. Managing file attachments—such as customer invoices, identification proofs, contracts, and inspection photos—is a standard requirement across Salesforce implementations. Building custom binary file uploaders with Apex controllers often results in heap size exceptions when files exceed 4–5 MB. The standard <lightning-file-upload> component solves this by uploading files directly to Salesforce Files via optimized streaming APIs, supporting large uploads up to 2 GB out of the box.
Read article
Topic Data Table Dynamic Search File Upload Lightning Web Components LWC Recipes Pagination Salesforce Development toast notifications
Data Table Dynamic Search File Upload Lightning Web Components LWC Recipes Pagination Salesforce Development toast notifications

Must-Have Salesforce LWC Recipes: 7 Essential UI Components for Developers

In plain words: Lightning Web Components (LWC) Recipes are modular, reusable code blueprints designed to solve everyday Salesforce UI challenges. Instead of writing custom components from scratch, developers use these proven recipes—covering dynamic search, custom pagination, data tables, file attachments, and drag-and-drop interfaces—to speed up project delivery and ensure high user adoption. Salesforce Lightning Web Components (LWC) have revolutionized user interface development by combining modern web standards like custom elements and shadow DOM with enterprise platform security. Whether you are building interactive dashboards, document upload workflows, or Kanban task boards, having a collection of reliable UI recipes saves development time and ensures consistent user experiences across your org.
Read article
Topic Integration & APIs
Salesforce Integration & APIs

Google Drive Salesforce Integration: Apex REST, OAuth 2.0 & Named Credentials Guide

In plain words: Integrating Google Drive with Salesforce allows your CRM to directly read, list, and upload files to Google Cloud storage. By authenticating via OAuth 2.0 and executing REST callouts in Apex, teams can offload heavy file storage from Salesforce, organize customer documents into Google Drive folders, and maintain real-time access right from record pages. Salesforce orgs frequently hit data and file storage limits when storing heavy contracts, collateral, and customer uploads as native ContentDocument records. Integrating directly with Google Drive via the Google Drive REST API v3 offers a cost-effective, scalable solution. This guide walks through setting up OAuth credentials in Google Cloud, structuring robust Apex callout methods, and executing multipart file uploads safely.
Read article
Topic Apex
Apex Development

Understanding Multipart Data and Boundaries for File Uploads in Salesforce Apex

In plain words: When you send data via an HTTP request, standard JSON usually works fine. However, if you need to upload a binary file (like a PDF or image) alongside text form fields in a single request, you must use a format called multipart/form-data . A boundary is a unique text divider placed between each piece of data so the receiving server knows where one file ends and the next form field begins. In Salesforce development, integrating with external REST APIs to upload files or documents is a frequent requirement. When the target API expects a file payload combined with metadata, simple JSON strings won't cut it. You need to construct a multipart HTTP request. Let's dive into how multipart data and boundary strings work under the hood, and look at a clean Apex implementation for handling file uploads.
Read article
Topic LWC
Lightning Web Components

How to Build a Custom Image Uploader in Salesforce LWC & Apex

In plain words: A custom image uploader in LWC reads a file selected in the browser, encodes it into a Base64 string using JavaScript's FileReader API, and passes that payload to an Apex controller to store it directly in Salesforce Files or send it to an external server. While standard components like lightning-file-upload work for basic attachments, creating a custom file uploader gives you full control over client-side file compression, validation, custom UI preview states, and tailored backend processing.
Read article
Apex Development

Upload Documents using REST API in Salesforce Apex

In plain words: You can upload documents programmatically in Salesforce using Apex by constructing an HTTP POST request targeting the Salesforce REST API. This method allows you to send base64-encoded files along with required parameters like folder IDs or document names directly through code. In Salesforce, Apex allows you to extend platform capabilities beyond the standard UI. A frequent requirement in enterprise integrations is uploading files and documents programmatically using REST endpoints. This guide demonstrates how to configure API access and build a dedicated Apex class to upload files securely.
Read article