feat: add GetTaskFile and RemoveAllTaskFiles methods

Complete the Task File API implementation with:
- GetTaskFile: retrieve single file metadata by ID
- RemoveAllTaskFiles: remove all files attached to a task
- Add Username/UserName fields to TaskFile struct
- Add TaskScope convenience methods: GetFile, RemoveFile,
  DownloadFile, RemoveAllFiles
- Comprehensive tests for all new methods

Closes: kanboard-amh
This commit is contained in:
Oliver Jakoubek 2026-01-27 17:01:21 +01:00
commit 280fff21a3
6 changed files with 297 additions and 2 deletions

View file

@ -281,3 +281,23 @@ func (t *TaskScope) UploadFile(ctx context.Context, filename string, content []b
}
return t.client.CreateTaskFile(ctx, int(task.ProjectID), t.taskID, filename, content)
}
// GetFile returns a file's metadata by ID.
func (t *TaskScope) GetFile(ctx context.Context, fileID int) (*TaskFile, error) {
return t.client.GetTaskFile(ctx, fileID)
}
// RemoveFile removes a file by ID.
func (t *TaskScope) RemoveFile(ctx context.Context, fileID int) error {
return t.client.RemoveTaskFile(ctx, fileID)
}
// DownloadFile downloads a file's content by ID.
func (t *TaskScope) DownloadFile(ctx context.Context, fileID int) ([]byte, error) {
return t.client.DownloadTaskFile(ctx, fileID)
}
// RemoveAllFiles removes all files from this task.
func (t *TaskScope) RemoveAllFiles(ctx context.Context) error {
return t.client.RemoveAllTaskFiles(ctx, t.taskID)
}