Implement File API methods
- GetAllTaskFiles: retrieve all files attached to a task - CreateTaskFile: upload file with base64 encoding - DownloadTaskFile: download file with base64 decoding - RemoveTaskFile: delete a task file - TaskScope.GetFiles and UploadFile for fluent API - Automatic base64 encoding/decoding for file content - Comprehensive test coverage
This commit is contained in:
parent
39ff0a90c8
commit
610998283b
4 changed files with 417 additions and 1 deletions
|
|
@ -266,3 +266,18 @@ func (t *TaskScope) LinkTo(ctx context.Context, oppositeTaskID, linkID int) erro
|
|||
_, err := t.client.CreateTaskLink(ctx, t.taskID, oppositeTaskID, linkID)
|
||||
return err
|
||||
}
|
||||
|
||||
// GetFiles returns all files attached to this task.
|
||||
func (t *TaskScope) GetFiles(ctx context.Context) ([]TaskFile, error) {
|
||||
return t.client.GetAllTaskFiles(ctx, t.taskID)
|
||||
}
|
||||
|
||||
// UploadFile uploads a file to this task and returns the file ID.
|
||||
// The file content is automatically base64 encoded.
|
||||
func (t *TaskScope) UploadFile(ctx context.Context, filename string, content []byte) (int, error) {
|
||||
task, err := t.Get(ctx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return t.client.CreateTaskFile(ctx, int(task.ProjectID), t.taskID, filename, content)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue