Update Saqel Platform: 2026-09-08 18:55:21
This commit is contained in:
@@ -365,11 +365,13 @@ class TeacherRepository {
|
||||
String? filePath,
|
||||
Uint8List? fileBytes,
|
||||
}) async {
|
||||
final stopwatch = Stopwatch()..start();
|
||||
final uploadUri = Uri.parse('$baseUrl${AppConfig.uploadVideoEndpoint}');
|
||||
try {
|
||||
final headers = await _authHeaders();
|
||||
final request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse('$baseUrl${AppConfig.uploadVideoEndpoint}'),
|
||||
uploadUri,
|
||||
);
|
||||
request.headers.addAll(headers..remove('Content-Type'));
|
||||
request.fields.addAll({
|
||||
@@ -380,6 +382,19 @@ class TeacherRepository {
|
||||
'subject': subject,
|
||||
'curriculum_key': curriculumKey,
|
||||
});
|
||||
AppLogger.request(
|
||||
method: 'POST',
|
||||
uri: uploadUri,
|
||||
headers: request.headers,
|
||||
body: {
|
||||
'title': title,
|
||||
'grade_level': gradeLevel,
|
||||
'subject': subject,
|
||||
'curriculum_key': curriculumKey,
|
||||
'file_name': fileName,
|
||||
'file_size_mb': fileSizeMb
|
||||
},
|
||||
);
|
||||
|
||||
final resolvedName = fileName ?? 'lesson.mp4';
|
||||
if (filePath != null && filePath.isNotEmpty) {
|
||||
@@ -401,6 +416,13 @@ class TeacherRepository {
|
||||
final streamed =
|
||||
await _client.send(request).timeout(const Duration(minutes: 10));
|
||||
final response = await http.Response.fromStream(streamed);
|
||||
AppLogger.response(
|
||||
method: 'POST',
|
||||
uri: uploadUri,
|
||||
statusCode: response.statusCode,
|
||||
responseBody: response.body,
|
||||
duration: stopwatch.elapsed,
|
||||
);
|
||||
|
||||
final decoded = json.decode(response.body) as Map<String, dynamic>;
|
||||
if (response.statusCode == 200 || response.statusCode == 201)
|
||||
@@ -410,6 +432,8 @@ class TeacherRepository {
|
||||
} on StateError {
|
||||
rethrow;
|
||||
} catch (error) {
|
||||
AppLogger.error('Lesson upload request failed',
|
||||
error: error, tag: 'TEACHER_REPO');
|
||||
throw StateError('تعذر رفع الحصة: $error');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user