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-13 12:47:46 -04:00
2023-09-01 14:45:41 -04:00
2024-11-11 13:59:05 -05:00
2024-04-16 09:22:41 -04:00
2024-06-13 09:43:44 -04:00
2023-09-01 14:45:41 -04:00
2025-06-13 12:47:46 -04:00
2024-04-16 09:22:41 -04:00
2025-06-02 11:26:26 -07:00
2025-06-13 12:47:46 -04:00
2024-06-13 09:43:44 -04:00
2024-07-18 13:43:53 -04:00
2023-09-01 14:45:41 -04:00
2023-09-01 14:45:41 -04:00
2023-09-01 14:45:41 -04:00
2025-06-12 09:46:49 -04:00
2024-10-08 14:45:51 -04:00
2024-06-13 09:43:44 -04:00
2025-06-13 12:47:46 -04:00
2025-06-13 12:47:46 -04:00
2023-09-01 14:45:41 -04:00
2025-01-17 09:16:29 -05:00
2023-09-01 14:45:41 -04:00
2023-09-01 14:45:41 -04:00
2025-03-12 09:48:05 -04:00
2025-03-03 14:58:39 -05:00
2023-11-07 15:20:57 -05:00
2025-01-22 16:20:13 -05:00
2024-03-25 11:09:17 -04:00
2025-02-25 16:55:44 -05:00
2024-03-14 23:53:47 -04:00
2024-06-17 14:25:36 -04:00
2023-10-26 09:04:13 -04:00