
Implementing Ui Bundle File Upload
Add Salesforce ContentVersion file upload with progress tracking to a React UI bundle without hand-rolling FormData or XHR.
Overview
Implementing UI Bundle File Upload is an agent skill for the Build phase that wires Salesforce UI bundle apps to the official upload() API with ContentVersion integration and progress callbacks instead of custom FormData
Install
npx skills add https://github.com/forcedotcom/afv-library --skill implementing-ui-bundle-file-uploadWhat is this skill?
- API-only package: programmatic upload() with onProgress—no exported FileUpload or useFileUpload
- Explicit anti-pattern: do not build upload from scratch with FormData or XHR
- Requires custom UI (input, dropzone, progress bars) you build against the upload API
- Source reference components are examples only—not importable from the package
- Install-and-wire workflow for uiBundles/*/src/ Salesforce UI bundle apps
Adoption & trust: 1.3k installs on skills.sh; 513 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need file attach UX in a uiBundles app but the platform ships programmatic upload APIs only, and rolling your own XHR risks missing ContentVersion integration and progress handling.
Who is it for?
Builders extending Salesforce UI bundles who want a guided API workflow and explicit guardrails against fake component imports.
Skip if: Projects without uiBundles/*/src/, non-Salesforce stacks, or teams that require a turnkey drop-in React FileUpload component from the package.
When should I use this skill?
Project contains uiBundles/*/src/ and the task involves uploading, attaching, or dropping files in a UI bundle app.
What do I get? / Deliverables
Your agent installs the package, calls upload() with onProgress, and you ship custom React UI that attaches files correctly to Salesforce ContentVersion.
- Custom React upload UI wired to upload()
- ContentVersion-backed file attachments with progress handling
Recommended Skills
Journey fit
File attach flows are implemented while wiring product UI to platform APIs during the build phase. Canonical shelf is integrations because the skill centers on ContentVersion upload APIs rather than generic React styling.
How it compares
Use instead of ad-hoc FormData/XHR upload snippets that bypass the AFV library ContentVersion path.
Common Questions / FAQ
Who is implementing-ui-bundle-file-upload for?
Solo and indie developers (and small teams) building React UI bundle apps on Salesforce AFV who need attach/drop/upload behavior tied to ContentVersion.
When should I use implementing-ui-bundle-file-upload?
During Build when your repo has uiBundles/*/src/ and the task adds uploading, attaching, or dropping files; also when an agent is tempted to import components that this API-only package does not export.
Is implementing-ui-bundle-file-upload safe to install?
Treat it as standard third-party workflow guidance: review the Security Audits panel on this Prism page and your org's package policies before enabling network/file access in agent runs.
SKILL.md
READMESKILL.md - Implementing Ui Bundle File Upload
# File Upload API (workflow) When the user wants file upload functionality in a React UI bundle, follow this workflow. This feature provides **APIs only** — you must build the UI components yourself using the provided APIs. ## CRITICAL: This is an API-only package The package exports **programmatic APIs**, not React components or hooks. You will: - Use the `upload()` function to handle file uploads with progress tracking - Build your own custom UI (file input, dropzone, progress bars, etc.) - Track upload progress through the `onProgress` callback **Do NOT:** - Expect pre-built components like `<FileUpload />` — they are not exported - Try to import React hooks like `useFileUpload` — they are not exported - Look for dropzone components — they are not exported The source code contains reference components for demonstration, but they are **not available** as imports. Use them as examples to build your own UI. ## 1. Install the package ```bash npm install @salesforce/ui-bundle-template-feature-react-file-upload ``` Dependencies are automatically installed: - `@salesforce/ui-bundle` (API client) - `@salesforce/sdk-data` (data SDK) ## 2. Understand the three upload patterns ### Pattern A: Basic upload (no record linking) Upload files to Salesforce and get back `contentBodyId` for each file. No ContentVersion record is created. **When to use:** - User wants to upload files first, then create/link them to a record later - Building a multi-step form where the record doesn't exist yet - Deferred record linking scenarios ```tsx import { upload } from "@salesforce/ui-bundle-template-feature-react-file-upload"; const results = await upload({ files: [file1, file2], onProgress: (progress) => { console.log(`${progress.fileName}: ${progress.status} - ${progress.progress}%`); }, }); // results[0].contentBodyId: "069..." (always available) // results[0].contentVersionId: undefined (no record linked) ``` ### Pattern B: Upload with immediate record linking Upload files and immediately link them to an existing Salesforce record by creating ContentVersion records. **When to use:** - Record already exists (Account, Opportunity, Case, etc.) - User wants files immediately attached to the record - Direct upload-and-attach scenarios ```tsx import { upload } from "@salesforce/ui-bundle-template-feature-react-file-upload"; const results = await upload({ files: [file1, file2], recordId: "001xx000000yyyy", // Existing record ID onProgress: (progress) => { console.log(`${progress.fileName}: ${progress.status} - ${progress.progress}%`); }, }); // results[0].contentBodyId: "069..." (always available) // results[0].contentVersionId: "068..." (linked to record) ``` ### Pattern C: Deferred record linking (record creation flow) Upload files without a record, then link them after the record is created. **When to use:** - Building a "create record with attachments" form - Record doesn't exist until form submission - Need to upload files before knowing the final record ID ```tsx import { upload, createContentVersion, } from "@salesforce/ui-bundle-template-feature-react-file-upload"; // Step 1: Upload files (no recordId) const uploadResults = await upload({ files: [file1, file2], onProgress: (progress) => console.log(progress), }); // Step 2: Create the record const newRecordId = await createRecord(formData); // Step 3: Link uploaded files to the new record for (const file of up