feat: add dedicated thumbnail upload endpoint for courses with old file cleanup and presigned URL generation.

This commit is contained in:
JakkrapartXD 2026-01-28 16:46:54 +07:00
parent b0383b78e9
commit b303c50865
2 changed files with 78 additions and 15 deletions

View file

@ -111,6 +111,29 @@ export class CoursesInstructorController {
return await CoursesInstructorService.createCourse(value, decoded.id, thumbnail);
}
/**
* thumbnail
* Upload course thumbnail image
* @param courseId - / Course ID
* @param file - / Image file
*/
@Post('{courseId}/thumbnail')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Thumbnail uploaded successfully')
@Response('401', 'Invalid or expired token')
@Response('400', 'Validation error')
public async uploadThumbnail(
@Request() request: any,
@Path() courseId: number,
@UploadedFile() file: Express.Multer.File
): Promise<{ code: number; message: string; data: { course_id: number; thumbnail_url: string } }> {
const token = request.headers.authorization?.replace('Bearer ', '');
if (!token) throw new ValidationError('No token provided');
if (!file.mimetype?.startsWith('image/')) throw new ValidationError('Only image files are allowed');
return await CoursesInstructorService.uploadThumbnail(token, courseId, file);
}
/**
* ()
* Delete a course (only primary instructor can delete)