tenantId); $homeworkId = HomeworkId::fromString($command->homeworkId); // Valider que le devoir existe $this->homeworkRepository->get($homeworkId, $tenantId); $attachmentId = HomeworkAttachmentId::generate(); $storagePath = sprintf('homework/%s/%s/%s/%s', $command->tenantId, $command->homeworkId, (string) $attachmentId, $command->filename); $content = file_get_contents($command->tempFilePath); if ($content === false) { throw PieceJointeInvalideException::lectureFichierImpossible($command->filename); } $this->fileStorage->upload($storagePath, $content, $command->mimeType); return new HomeworkAttachment( id: $attachmentId, filename: $command->filename, filePath: $storagePath, fileSize: $command->fileSize, mimeType: $command->mimeType, uploadedAt: $this->clock->now(), ); } }