Retrieve File
Retrieves detailed information about a specific file by its ID.
HTTP Request
GET/api/media/files/:id
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the file |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3response = requests.get('http://www.example.com/api/media/files/123',
4 headers={'Authorization': 'Token <your_api_key>'}
5)
6print(response.json())1curl "http://www.example.com/api/media/files/123" \
2-H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | File retrieved successfully |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | File not found |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the file |
| type | String | File type (read-only, auto-detected) |
| user | Object | User who uploaded the file with id, username, full_name |
| f | String | File URL/path |
| name | String | Original filename |
| description | String | File description |
| size | Integer | File size in bytes (read-only) |
| human_readable_size | String | Human-readable file size (e.g., "2.5 MB") |
| width | Integer | Image width in pixels (images only, read-only) |
| height | Integer | Image height in pixels (images only, read-only) |
| mode | String | Image color mode (images only, read-only) |
| created_at | String (ISO 8601) | Timestamp when file was uploaded |
| updated_at | String (ISO 8601) | Timestamp when file was last updated |
Notes
- The file ID must exist in the system
- width, height, and mode fields are only present for image files
- File type is automatically detected and cannot be modified
- The user object contains information about who uploaded the file
- File size is provided in both raw bytes and human-readable format