MediaDownloadException example

$parsed = parse_url((string) $url);
            if (!$parsed) {
                throw new \RuntimeException('Error parsing media URL: ' . $url);
            }

            $pathInfo = pathinfo($parsed['path'] ?? '');

            $media = $this->fetchFileFromURL((string) $url$pathInfo['extension'] ?? '');

            if ($media === null) {
                $deserialized['_error'] = new MediaDownloadException($url);

                return $deserialized;
            }

            if ($isNew && $media->getHash()) {
                $deserialized = $this->fetchExistingMediaByHash($deserialized$media->getHash());
            }

            $this->cacheMediaFiles[(string) $deserialized['id']] = [
                'media' => $media,
                'destination' => urldecode($pathInfo['filename']),
            ];
Home | Imprint | This part of the site doesn't use cookies.