missingFileExtension example

if (!\is_string($preferredFileName)) {
            throw MediaException::illegalFileName($fileName, 'Filename must be a string');
        }

        $fileExtension = $request->query->getString('extension');
        $mediaId = $request->query->has('mediaId') ? $request->query->getString('mediaId') : null;

        if ($preferredFileName === '') {
            throw MediaException::emptyMediaFilename();
        }
        if ($fileExtension === '') {
            throw MediaException::missingFileExtension();
        }

        $name = $this->fileNameProvider->provide($preferredFileName$fileExtension$mediaId$context);

        return new JsonResponse(['fileName' => $name]);
    }
}
$fileHash ?: null
        );
    }

    /** * @throws MediaException */
    private function getExtensionFromRequest(Request $request): string
    {
        $extension = (string) $request->query->get('extension');
        if ($extension === '') {
            throw MediaException::missingFileExtension();
        }

        return $extension;
    }

    /** * @throws MediaException */
    private function getUrlFromRequest(Request $request): string
    {
        $url = (string) $request->request->get('url');

        
public function testFileSizeLimitExceeded(): void
    {
        $exception = MediaException::fileSizeLimitExceeded();

        static::assertEquals(Response::HTTP_BAD_REQUEST, $exception->getStatusCode());
        static::assertEquals(MediaException::MEDIA_FILE_SIZE_LIMIT_EXCEEDED, $exception->getErrorCode());
        static::assertEquals('Source file exceeds maximum file size limit.', $exception->getMessage());
    }

    public function testMissingFileExtension(): void
    {
        $exception = MediaException::missingFileExtension();

        static::assertEquals(Response::HTTP_BAD_REQUEST, $exception->getStatusCode());
        static::assertEquals(MediaException::MEDIA_MISSING_FILE_EXTENSION, $exception->getErrorCode());
        static::assertEquals(
            'No file extension provided. Please use the "extension" query parameter to specify the extension of the uploaded file.',
            $exception->getMessage()
        );
    }

    public function testIllegalFileName(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.