mirror of
https://github.com/immich-app/immich.git
synced 2026-02-28 17:49:05 +03:00
**Root cause:** The autogenerated Dart OpenAPI client (`UsersApi.createProfileImage()`) had two issues: 1. It set `Content-Type: multipart/form-data` without a boundary, which overrode the correct header that Dart's `MultipartRequest` would set (`multipart/form-data; boundary=...`). 2. It added the file to both `mp.fields` and `mp.files`, creating a duplicate text field. **Result:** Multer on the server failed to parse the multipart body, so `@UploadedFile()` was `undefined` → accessing `file.path` in `UserService.createProfileImage()` threw → **500 Internal Server Error**. **Workaround:** Bypass the autogenerated method in `UserApiRepository.createProfileImage()` and send the multipart request directly using the same `ApiClient` (basePath + auth), ensuring: - No manual `Content-Type` header (let `MultipartRequest` set it with boundary) - File only in `mp.files`, not `mp.fields` - Proper filename fallback
Infrastructure Layer
This directory contains the infrastructure layer of Immich. The infrastructure layer is responsible for the implementation details of the app. It includes data sources, APIs, and other external dependencies.
Structure
- Entities: These are the classes that define the database schema for the domain models.
- Repositories: These are the actual implementation of the domain interfaces. A single interface might have multiple implementations.
- Utils: These are utility classes and functions specific to infrastructure implementations.
infrastructure/
├── entities/
│ └── user.entity.dart
├── repositories/
│ └── user.repository.dart
└── utils/
└── database_utils.dart
Usage
The infrastructure layer provides concrete implementations of repository interfaces defined in the domain layer. These implementations are exposed through Riverpod providers in the root providers directory.
// In domain/services/user.service.dart
final userRepository = ref.watch(userRepositoryProvider);
final user = await userRepository.getUser(userId);
The domain layer should never directly instantiate repository implementations, but instead receive them through dependency injection.