detectMimeTypeFromBuffer example

if (!$iconPath = $paymentMethod->getIcon()) {
            return null;
        }

        $icon = $this->appLoader->loadFile($manifest->getPath()$iconPath);
        if (!$icon) {
            return null;
        }

        $fileName = sprintf('payment_app_%s_%s', $manifest->getMetadata()->getName()$paymentMethod->getIdentifier());
        $extension = pathinfo($paymentMethod->getIcon() ?? '', \PATHINFO_EXTENSION);
        $mimeType = $this->mimeDetector->detectMimeTypeFromBuffer($icon);
        $mediaId = $existing !== null ? $existing->getOriginalMediaId() : null;

        if (!$mimeType) {
            return null;
        }

        return $this->mediaService->saveFile(
            $icon,
            $extension,
            $mimeType,
            $fileName,
            
Home | Imprint | This part of the site doesn't use cookies.