upload functionality
This commit is contained in:
@@ -590,6 +590,28 @@ x-upload-url: /pets/{id}/photo
|
||||
|
||||
POST endpoint for file upload. The `{id}` placeholder is replaced with the current record ID.
|
||||
|
||||
#### `x-upload` (optional)
|
||||
|
||||
```yaml
|
||||
path:
|
||||
type: string
|
||||
x-upload:
|
||||
type: file # one of: image, pdf, html, csv, file
|
||||
url: /uploads # POST endpoint that accepts raw binary + Content-Disposition header
|
||||
```
|
||||
|
||||
Changes the form field to a file upload component. The file is POSTed as raw binary (`application/octet-stream`) to the specified `url` with a `Content-Disposition: attachment; filename="..."` header. The response must contain a `saved_as` field, which is stored as the field value.
|
||||
|
||||
| `type` | Display |
|
||||
|------------|--------------------------------------------------|
|
||||
| `image` | `<Avatar src="/uploads/{value}" />` |
|
||||
| `pdf` | Clickable chip linking to `/uploads/{value}` |
|
||||
| `html` | Clickable chip linking to `/uploads/{value}` |
|
||||
| `csv` | Clickable chip linking to `/uploads/{value}` |
|
||||
| `file` | Clickable chip linking to `/uploads/{value}` |
|
||||
|
||||
The chip includes a delete (X) button to replace the file.
|
||||
|
||||
### Property Types That Trigger Special Renderers
|
||||
|
||||
| Condition | Form Renderer | List/Detail Renderer |
|
||||
@@ -602,6 +624,7 @@ POST endpoint for file upload. The `{id}` placeholder is replaced with the curre
|
||||
| `format: date` | `DateField` (date picker) | Typography |
|
||||
| `format: date-time` | `DateField` (datetime-local picker) | Typography |
|
||||
| `x-ui-type: image` | `ImageField` (upload button + preview) | `Avatar` |
|
||||
| `x-upload` exists | `FileUploadField` (upload button + chip/Avatar) | Chip or Avatar |
|
||||
| `$ref` without `x-fk` | Disabled TextField with JSON | `InlineRefField` (chips or displayFormat) |
|
||||
| None of the above (default) | `StringField` (text input) | Typography |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user