DashForDevsDocs
DocsNewsAPI v1
dashfordevs.comSign in

© 2026 DashForDevs

DocsNewsdashfordevs.comLegalStatus
DocsMedia & FilesUpload Files
Introduction
Getting Started
Authentication
Products
Categories
Cart
Checkout
Blog
Reviews
Webhooks
Customers
Orders
Inventory
Shipping
Discounts
Affiliates
Email
Media & Files
Upload FilesImage URLs & CDNMedia LibraryFile Size Limits
Analytics & Tracking
Locations
Tax
Global Data
SEO
Error Handling
Geography
Finance
Automations
Page Types
Surveys
Billing & Subscriptions
Storefront Payments
SDK Reference
REST API
Storefront Architecture
Notifications
Security
Team & Permissions
Migrations & Import
Calendar & Appointments
Contact Forms
AI Bots
Dashboard API
Deployment
Changelog
Troubleshooting
Recipes
CLI & Deployment
Image Pipeline
White-label Platforms
Records Engine
Platform Modules
Platform Security
Site Keys & Client Sites
Use Cases
Operations

Upload Files

Upload images and documents to the media library.

Updated March 29, 2026

On this page
  • Overview
  • SDK Usage
  • Check Allowed File Types
  • File Upload Component
  • REST API
  • Next Steps

Overview

Upload files (images, documents) to the DashForDevs CDN. Uploaded files get a permanent URL for use in products, blog posts, reviews, and more.

SDK Usage

typescript
import dash from "@/lib/dash"

// Upload single file
const { success, url, filename, size } = await dash.upload.file(fileObject, {
  onProgress: (percent) => console.log(`${percent}% uploaded`),
})

// Upload multiple files
const results = await dash.upload.files([file1, file2, file3], {
  onFileProgress: (index, percent) => console.log(`File ${index}: ${percent}%`),
  onOverallProgress: (percent) => console.log(`Overall: ${percent}%`),
})

Check Allowed File Types

typescript
// Check if a file is allowed
const { allowed, reason } = await dash.upload.isAllowed("photo.jpg")

// Get full list
const allowed = await dash.upload.getAllowedExtensions()
// ["jpg", "jpeg", "png", "gif", "webp", "pdf", ...]

const blocked = await dash.upload.getBlockedExtensions()
// ["exe", "bat", "cmd", ...]

File Upload Component

typescript
"use client"
import { useState } from "react"
import dash from "@/lib/dash"

export function FileUploader({ onUploaded }) {
  const [uploading, setUploading] = useState(false)
  const [progress, setProgress] = useState(0)

  async function handleChange(e) {
    const file = e.target.files[0]
    if (!file) return

    setUploading(true)
    const { url } = await dash.upload.file(file, {
      onProgress: setProgress,
    })
    setUploading(false)
    onUploaded(url)
  }

  return (
    <div>
      <input type="file" onChange={handleChange} disabled={uploading} />
      {uploading && <p>Uploading... {progress}%</p>}
    </div>
  )
}

REST API

shell
POST /storefront/upload
X-API-Key: pk_live_your_key
Content-Type: multipart/form-data

# Include file as form data

Next Steps

  • Image URLs & CDN — How CDN works
  • File Size Limits — Upload restrictions
  • Submit Review — Uploading review photos
PreviousContact FormsNextImage URLs & CDN

On this page

  • Overview
  • SDK Usage
  • Check Allowed File Types
  • File Upload Component
  • REST API
  • Next Steps