mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Problem After #53183 and #52567 have been addressed, we should strengthen the interconnections between the UI library and the rest of the Supabase ecosystem. ## Solution - Adds contextual links for `/library`, Auth / Realtime category pages, and specific Auth / Realtime components. Hits top-level product pages, docs, kb, and blogs. ## Preview links N/A, link changes are relatively atomic so easier to review without many preview links. --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
84 lines
3.1 KiB
Plaintext
84 lines
3.1 KiB
Plaintext
---
|
|
title: Dropzone (File Upload)
|
|
description: Displays a control for easier uploading of files directly to Supabase Storage
|
|
preview: |-
|
|
<BlockOverview name="dropzone-react" showFiles>
|
|
<ComponentPreview
|
|
name="dropzone-demo"
|
|
description="A file upload dropzone that accepts dragged or selected files, previews images, shows validation errors, and uploads to Supabase Storage."
|
|
showCode={false}
|
|
/>
|
|
</BlockOverview>
|
|
---
|
|
|
|
## Installation
|
|
|
|
<BlockItem name="dropzone-react" />
|
|
|
|
## Introduction
|
|
|
|
Uploading files should be easy—this component handles the tricky parts for you.
|
|
|
|
The File Upload component makes it easy to add file uploads to your app, with built-in support for drag-and-drop, file type restrictions, image previews, and configurable limits on file size and number of files. All the essentials, ready to go.
|
|
|
|
**Features**
|
|
|
|
- Drag-and-drop support
|
|
- Multiple file uploads
|
|
- File size and count limits
|
|
- Image previews for supported file types
|
|
- MIME type restrictions
|
|
- Invalid file handling
|
|
- Success and error states with clear feedback
|
|
|
|
## Usage
|
|
|
|
- Simply add this `<Dropzone />` component to your page and it will handle the rest.
|
|
- For control over file upload, you can pass in a `props` object to the component.
|
|
|
|
```tsx
|
|
import { Dropzone, DropzoneContent, DropzoneEmptyState } from '@/components/dropzone'
|
|
import { useSupabaseUpload } from '@/hooks/use-supabase-upload'
|
|
|
|
const FileUploadDemo = () => {
|
|
const props = useSupabaseUpload({
|
|
bucketName: 'test',
|
|
path: 'test',
|
|
allowedMimeTypes: ['image/*'],
|
|
maxFiles: 2,
|
|
maxFileSize: 1000 * 1000 * 10, // 10MB,
|
|
})
|
|
|
|
return (
|
|
<div className="w-[500px]">
|
|
<Dropzone {...props}>
|
|
<DropzoneEmptyState />
|
|
<DropzoneContent />
|
|
</Dropzone>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export { FileUploadDemo }
|
|
```
|
|
|
|
## Props
|
|
|
|
| Prop | Type | Default | Description |
|
|
| ------------------ | ---------- | ------- | ---------------------------------------------------- |
|
|
| `bucketName` | `string` | `null` | The name of the Supabase Storage bucket to upload to |
|
|
| `path` | `string` | `null` | The path or subfolder to upload the file to |
|
|
| `allowedMimeTypes` | `string[]` | `[]` | The MIME types to allow for upload |
|
|
| `maxFiles` | `number` | `1` | Maximum number of files to upload |
|
|
| `maxFileSize` | `number` | `1000` | Maximum file size in bytes |
|
|
|
|
## Further reading
|
|
|
|
- [Creating buckets](https://supabase.com/docs/guides/storage/buckets/creating-buckets)
|
|
- [Access control](https://supabase.com/docs/guides/storage/security/access-control)
|
|
- [Standard uploads](https://supabase.com/docs/guides/storage/uploads/standard-uploads)
|
|
- [Resumable uploads](https://supabase.com/docs/guides/storage/uploads/resumable-uploads)
|
|
- [File limits](https://supabase.com/docs/guides/storage/uploads/file-limits)
|
|
- [Image transformations](https://supabase.com/docs/guides/storage/serving/image-transformations)
|
|
- [Storage helper functions](https://supabase.com/docs/guides/storage/schema/helper-functions)
|