Kendell Joseph
f2e04222f4
feat: admin upload controls (#11615)
### What?
Adds the ability to add additional components to the file upload
component.
```ts
export const Media: CollectionConfig = {
slug: 'media',
upload: {
admin: {
components: {
controls: [
'/collections/components/Control/index.js#UploadControl',
],
},
},
},
fields: [],
}
```

### Provider
Use the `useUploadControls` provider to either `setUploadControlFile`
passing a file object, or set the file by url using
`setUploadControlFileUrl`.
```tsx
'use client'
import { Button, useUploadControls } from '@payloadcms/ui'
import React, { useCallback } from 'react'
export const UploadControl = () => {
const { setUploadControlFile, setUploadControlFileUrl } = useUploadControls()
const loadFromFile = useCallback(async () => {
const response = await fetch('https://payloadcms.com/images/universal-truth.jpg')
const blob = await response.blob()
const file = new File([blob], 'universal-truth.jpg', { type: 'image/jpeg' })
setUploadControlFile(file)
}, [setUploadControlFile])
const loadFromUrl = useCallback(() => {
setUploadControlFileUrl('https://payloadcms.com/images/universal-truth.jpg')
}, [setUploadControlFileUrl])
return (
<div>
<Button id="load-from-file-upload-button" onClick={loadFromFile}>
Load from File
</Button>
<br />
<Button id="load-from-url-upload-button" onClick={loadFromUrl}>
Load from URL
</Button>
</div>
)
}
```
### Why?
Add the ability to use a custom component to select a document to
upload.
2025-06-13 12:47:46 -04:00
..
2025-06-09 14:43:03 -04:00
2025-06-11 20:59:19 +00:00
2025-06-13 14:11:13 +00:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-12 19:37:07 +03:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-02 22:01:07 +00:00
2025-03-11 17:19:36 -04:00
2025-06-11 20:59:19 +00:00
2025-06-09 14:43:03 -04:00
2025-06-09 14:43:03 -04:00
2025-06-09 14:43:03 -04:00
2025-06-13 12:47:46 -04:00
2025-06-13 12:47:46 -04:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-09 14:43:03 -04:00
2025-06-13 12:35:06 -04:00
2025-06-09 14:43:03 -04:00
2025-06-13 03:39:15 -07:00
2025-06-11 20:59:19 +00:00
2025-06-12 15:43:00 +01:00
2025-06-11 20:59:19 +00:00
2025-06-09 14:43:03 -04:00
2025-06-09 14:43:03 -04:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-11 20:59:19 +00:00
2025-06-13 12:47:46 -04:00