mirror of
https://github.com/immich-app/immich.git
synced 2026-02-28 09:38:43 +03:00
Revert "temporary workaround for 500 error"
This reverts commit 8436cd402632ca7be9272a1c72fdaf0763dcefb6.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
@@ -19,34 +18,8 @@ class UserApiRepository extends ApiRepository {
|
||||
}
|
||||
|
||||
Future<String> createProfileImage({required String name, required Uint8List data}) async {
|
||||
// Workaround: the autogenerated OpenAPI client forces `Content-Type: multipart/form-data`
|
||||
// without a boundary, which can break multer parsing server-side.
|
||||
// We bypass `UsersApi.createProfileImage()` and send the multipart request directly,
|
||||
// while still reusing the configured basePath + auth headers + http client.
|
||||
final apiClient = _api.apiClient;
|
||||
|
||||
final headers = <String, String>{};
|
||||
await apiClient.authentication?.applyToParams(<QueryParam>[], headers);
|
||||
headers.addAll(apiClient.defaultHeaderMap);
|
||||
headers.remove('Content-Type');
|
||||
headers.remove('content-type');
|
||||
|
||||
final filename = name.isNotEmpty ? name : 'profile-picture.png';
|
||||
final uri = Uri.parse('${apiClient.basePath}/users/profile-image');
|
||||
|
||||
final request = MultipartRequest('POST', uri)
|
||||
..headers.addAll(headers)
|
||||
..files.add(MultipartFile.fromBytes('file', data, filename: filename));
|
||||
|
||||
final streamed = await apiClient.client.send(request);
|
||||
final response = await Response.fromStream(streamed);
|
||||
|
||||
if (response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, response.body);
|
||||
}
|
||||
|
||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
return body['profileImagePath'] as String;
|
||||
final res = await checkNull(_api.createProfileImage(MultipartFile.fromBytes('file', data, filename: name)));
|
||||
return res.profileImagePath;
|
||||
}
|
||||
|
||||
Future<List<UserDto>> getAll() async {
|
||||
|
||||
Reference in New Issue
Block a user