feat(api): default download endpoint to processed file version
- Change default `version` param from 'original' to 'processed' so
GET /api/files/{id}/download (no param) returns the processed file
- Update docstring to reflect new default
- Add tests: ?version=processed, default→processed, invalid→400
- Fix test_file_download_missing_mime_type to use explicit ?version=original
- Add File Download section to docs/API.md
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
+26
@@ -388,6 +388,32 @@ curl "http://<your-instance>/api/files/123/preview?version=processed"
|
||||
- `404`: File not found in database or on disk
|
||||
- `400`: Invalid version parameter
|
||||
|
||||
### File Download
|
||||
|
||||
**GET** `/api/files/{file_id}/download`
|
||||
|
||||
Download a file as an attachment. The `Content-Disposition` header is set to `attachment` with the original filename so the browser prompts a save dialog.
|
||||
|
||||
**Parameters**:
|
||||
- `version` (optional, default: `processed`): Either `processed` or `original`
|
||||
- `processed` *(default)*: Downloads the post-processing file (with embedded metadata)
|
||||
- `original`: Downloads the raw file as originally uploaded
|
||||
|
||||
**Response**: File content with `Content-Disposition: attachment; filename="<original_filename>"`.
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
# Download processed file (default)
|
||||
curl -OJ "http://<your-instance>/api/files/123/download"
|
||||
|
||||
# Download original upload
|
||||
curl -OJ "http://<your-instance>/api/files/123/download?version=original"
|
||||
```
|
||||
|
||||
**Error Responses**:
|
||||
- `404`: File not found in database or on disk
|
||||
- `400`: Invalid `version` parameter (must be `processed` or `original`)
|
||||
|
||||
### Batch Processing
|
||||
|
||||
**POST** `/api/processall`
|
||||
|
||||
Reference in New Issue
Block a user