Это мой файл репозитория.dart:
Код: Выделить всё
Future uploadProfilePhoto(File photo, String uid) async {
try {
var request = http.MultipartRequest(
'POST',
Uri.parse(
'https://7234-122-169-82-170.ngrok-free.app/api/auth/profilePicture/upload?uid=$uid'),
);
var photoFile = await http.MultipartFile.fromPath('photo', photo.path);
request.files.add(photoFile);
var response = await request.send();
if (response.statusCode == 200) {
var responseBody = await response.stream.bytesToString();
return responseBody;
} else {
throw Exception('Failed to upload photo: ${response.reasonPhrase}');
}
} catch (e) {
debugPrint('Error uploading photo: $e');
throw Exception(e);
}
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... in-flutter