Add attachment deletion route and automatic cleanup on record deletion
Co-authored-by: aiulian25 <17886483+aiulian25@users.noreply.github.com>
This commit is contained in:
parent
0eb54dfd30
commit
90143f7dc0
2 changed files with 76 additions and 0 deletions
|
|
@ -85,6 +85,41 @@ Download or view an attachment.
|
|||
|
||||
---
|
||||
|
||||
### Delete Attachment
|
||||
Delete an attachment file.
|
||||
|
||||
**Endpoint:** `DELETE /api/attachments/delete`
|
||||
|
||||
**Authentication:** Required
|
||||
|
||||
**Query Parameters:**
|
||||
- `path` (required): Relative path to the attachment (e.g., `attachments/filename.pdf`)
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"message": "Attachment deleted successfully"
|
||||
}
|
||||
```
|
||||
|
||||
**Error Responses:**
|
||||
- 400: No file path provided
|
||||
- 403: Invalid file path (security violation)
|
||||
- 404: File not found
|
||||
- 500: Server error during deletion
|
||||
|
||||
**Example:**
|
||||
```javascript
|
||||
await fetch(`/api/attachments/delete?path=${encodeURIComponent(filePath)}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include'
|
||||
});
|
||||
```
|
||||
|
||||
**Note:** When deleting a fuel record, service record, or recurring expense, the associated attachment is automatically deleted.
|
||||
|
||||
---
|
||||
|
||||
## Data Models
|
||||
|
||||
### FuelRecord
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue