pub async fn upload_files(
__arg0: State<AppState>,
__arg1: Path<(i64, i64)>,
multipart: Multipart,
) -> impl IntoResponse
Expand description
POST /api/modules/{module_id}/assignments/{assignment_id}/files
Upload a single file to an assignment. Only accessible by lecturers assigned to the module.
§Path Parameters
module_id
(i64): The ID of the module containing the assignmentassignment_id
(i64): The ID of the assignment to upload the file to
§Request Body (Multipart Form Data)
file_type
(string, required): The type of file. Must be one of:spec
,main
,memo
, etc.file
(file, required): The file to upload. Only one file per request is allowed.
§Responses
201 Created
{
"success": true,
"message": "File uploaded successfully",
"data": {
"id": 123,
"assignment_id": 456,
"filename": "assignment.pdf",
"path": "module_456/assignment_789/assignment.pdf",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
}
400 Bad Request
{
"success": false,
"message": "Invalid file_type" // or "Missing required field: file_type" or "Missing file upload" or "Empty file provided" or "Only one file may be uploaded per request"
}
404 Not Found
{
"success": false,
"message": "Assignment not found"
}
500 Internal Server Error
{
"success": false,
"message": "Database error" // or "Failed to save file"
}