WrongMediaTypeForReplaceException example

throw new InvalidArgumentException(sprintf('Media with id %s not found', $mediaId));
        }

        $filePath = $file->getRealPath();
        if (!\is_string($filePath)) {
            throw new UnexpectedValueException(sprintf('Could not get path of file "%s"', $file->getFilename()));
        }

        $uploadedFileExtension = $this->getExtension($file);

        if ($media->getType() !== $this->mappingService->getType($uploadedFileExtension)) {
            throw new WrongMediaTypeForReplaceException($media->getType());
        }

        if ($this->mappingService->isAllowed($uploadedFileExtension) === false) {
            throw new MediaFileExtensionNotAllowedException($uploadedFileExtension);
        }

        $fileContent = file_get_contents($filePath);
        $oldExtension = strtolower($media->getExtension());
        $newExtension = strtolower($this->getExtension($file));

        $newFileName = null;
        
Home | Imprint | This part of the site doesn't use cookies.