Obtain a String of a thumbnail encoded in Base64

@param $uri
@param bool $defaultAllowed
@return mixed
549518
public function getThumbnailAsBase64String($uri, $defaultAllowed = false)
    {
        $url = self::makeUrl($uri, $defaultAllowed);
        $response = $this->service->makeRequest($url, array(200, 204), 'GET', null, true, 'application/json', 'text/plain');

        return $response['body'];
    }
18639
public static function uriToPath(string $uri)
    {
        $fragments = parse_url($uri);
        if ($fragments === false || !isset($fragments['scheme']) || $fragments['scheme'] !== 'file') {
            throw new \InvalidArgumentException("Not a valid file URI: $uri");
        }
        $filepath = urldecode((string) $fragments['path']);
        if (strpos($filepath, ':') !== false) {
            if ($filepath[0] === '/') {
                $filepath = substr($filepath, 1);
            }
            $filepath = str_replace('/', '\\', $filepath);
        }
        return $filepath;
    }
942328
function urlFor($internalUri, $locale = NULL){
        $internalUri= ltrim($internalUri, '/');
        if($locale == NULL)return $this->request->realBaseUrl . $internalUri;
        else return $this->request->realBaseUrl . $locale . '/' . $internalUri;
    }
79001
function requestURI( $uri )
    {
        $parsed = parse_url( $uri );

        $return = '';
        if ( isset( $parsed['user'] ) )
        {
            $return .= $parsed['user'] . '@' . $parsed['pass'];
        }
        $return .= rtrim( $parsed['path'], '/' ) . '/' . $this->Name;

        if ( isset( $parsed['query'] ) )
        {
            $return  .= '?' . $parsed['query'];
        }
        if ( isset( $parsed['fragment'] ) )
        {
            $return .= '#' . $parsed['fragment'];
        }

        return $return;
    }
1186116
private static function parseURI($uri){
        //Remove protocol (for clarity).
        $uri = substr($uri, strlen('mmap://'));
        $parts = explode('?', $uri);

        $file_name_block_size = explode(':', $parts[0]);

        if(!isset($file_name_block_size[1])){
            throw new \Exception(sprintf('%s is not a valid uri', $uri));
        }

        $parsed = [];

        list($parsed['file_name'], $parsed['block_size']) = $file_name_block_size;

        if(isset($parts[1])){
            //Extra params
            parse_str($parts[1], $parsed['options']);
        } else {
            $parsed['options'] = [];
        }

        return $parsed;
    }
460792
public function setURIString( $uri, $fullInitialize = true )
    {
        if ( strlen( $uri ) > 0 and
             $uri[0] == '/' )
            $uri = substr( $uri, 1 );

        $uri = eZURI::decodeIRI( $uri );

        $this->URI = $uri;
        $this->URIArray = explode( '/', $uri );
        $this->Index = 0;

        if ( !$fullInitialize )
            return;

        $this->OriginalURI = $uri;
        $this->UserArray = array();

        unset( $paramName, $paramValue );
        foreach ( array_keys( $this->URIArray ) as $key )
        {
            if ( !isset( $this->URIArray[$key] ) )
                continue;

            if ( preg_match( "/^[\(][a-zA-Z0-9_]+[\)]/", $this->URIArray[$key] ) )
            {
                if ( isset( $paramName, $paramValue ) )
                {
                    $this->UserArray[ $paramName ] = $paramValue;
                    unset( $paramName, $paramValue );
                }
                $paramName = substr( $this->URIArray[$key], 1, strlen( $this->URIArray[$key] ) - 2 );
                if ( isset( $this->URIArray[$key+1] ) )
                {
                    $this->UserArray[ $paramName ] = $this->URIArray[$key+1];
                    unset( $this->URIArray[$key+1] );
                }
                else
                    $this->UserArray[ $paramName ] = "";
                unset( $this->URIArray[$key] );
            }
            else if ( isset( $paramName ) )
            {
                $this->UserArray[ $paramName ] .= '/' . $this->URIArray[$key];
                unset( $this->URIArray[$key] );
            }
        }

        // Remake the URI without any user parameters
        $this->URI = implode( '/', $this->URIArray );

        if ( eZINI::instance( 'template.ini' )->variable( 'ControlSettings', 'AllowUserVariables' ) == 'false' )
        {
            $this->UserArray = array();
        }
        // Convert filter string to current locale
        $this->convertFilterString();
    }
617491
public static function get(string $key, $defaultValue = null, string $storage = 'global')
    {
        if (!self::has($key)) {
            return $defaultValue;
        }

        // Get content.
        $fileKey = self::key($key);
        $content = null;
        if (file_exists(self::$path . '/' . $storage . '/' . $fileKey)) {
            $content = file_get_contents(self::$path . '/' . $storage . '/' . $fileKey);
        }

        // Extract expiration.
        $markerPos = strpos($content, self::$marker);
        $expiration = null;
        if ($markerPos !== false) {
            $expiration = substr($content, 0, $markerPos);
        }

        // Extract content.
        if ($expiration < time()) {
            self::forget($key);
        } else {
            return unserialize(substr($content, $markerPos + strlen(self::$marker)));
        }

        return $defaultValue;
    }
1248735
public function parse($uri)
    {
        if (($scheme = static::parseScheme($uri)) !== null) {
            $this->setScheme($scheme);
            $uri = substr($uri, strlen($scheme) + 1);
        }

        $parts = explode(',', $uri, 2);

        if (count($parts) > 1) {
            $mimeType = array_shift($parts);
            if (';base64' === substr($mimeType, -7)) {
                $this->encoding = 'base64';
                $mimeType = substr($mimeType, 0, -7);
            }
            $this->setMimeType($mimeType);
        }

        $this->rawData = array_shift($parts);

        return $this;
    }
437383
protected function get($uri=null)
    {
        if (!is_null($uri)) {
            if (!($this->getCrudService()->isInScope($uri))) {
                throw new common_exception_PreConditionFailure("The URI must be a valid resource under the root Class");
            }
            return $this->getCrudService()->get($uri);
        } else {
            return $this->getCrudService()->getAll();
        }
    }
72350
private function parseUri(string $uri): array
    {
        $defaults = [
            'scheme'   => '',
            'host'     => '',
            'port'     => '',
            'user'     => '',
            'pass'     => '',
            'path'     => '',
            'query'    => '',
            'fragment' => '',
        ];

        if (0 === strpos($uri, 'file://')) {
            // parse_url botches this up
            preg_match('@file://(?P<path>[^#]*)(?P<fragment>#.*)?@', $uri, $matches);

            return array_merge($defaults, array_intersect_key($matches, $defaults));
        }

        return array_merge($defaults, array_intersect_key(parse_url($uri), $defaults));
    }
1040910
public function standardizeUri(string $uri): string {
        if ($uri == '') {
            throw new BadMethodCallException('URI is empty');
        }
        if (substr($uri, 0, 1) === '/') {
            $uri = substr($uri, 1);
        }
        $uri = preg_replace('|^https?://[^/]+/rest/(tx:[-0-9a-zA-Z]+/)?|', '', $uri);
        $uri = $this->apiUrl . '/' . $uri;
        return $uri;
    }
442762
public function getRawUri($farExpires = true, $debug = false)
    {
        $path = rtrim($this->minAppUri, '/') . '/';
        if (! $this->rewriteWorks) {
            $path .= '?';
        }
        if (null === $this->_groupKey) {
            // @todo: implement shortest uri
            $path = self::_getShortestUri($this->_filePaths, $path);
        } else {
            $path .= "g=" . $this->_groupKey;
        }
        if ($debug) {
            $path .= "&debug";
        } elseif ($farExpires && $this->_lastModified) {
            $path .= "&" . $this->_lastModified;
        }

        return $path;
    }
1006636
private static function checkProvidedUri($uri)
    {
        $returnValue = (string) '';

        
        if($uri != '') {
        	if(common_Utils::isUri($uri)){
        		$returnValue = $uri;
        	}
        	else{
        		throw new common_Exception("Could not create new Resource, malformed URI provided: '" . $uri . "'.");
        	}
        }
        else{
        	$returnValue = common_Utils::getNewUri();
        }
        

        return (string) $returnValue;
    }
467757
public function getSafeUri()
    {
        static $safe = array(
            '%2F' => '/',
            '%2f' => '/',
        );

        if ( empty( $this->uri ) )
        {
            return null;
        }

        return strtr( rawurlencode( $this->uri ), $safe );
    }
592929
public function getUrl($fullBase = true)
    {
        is_true_or_fail(!empty($this->target), __d(
            'thumber',
            'Missing path of the generated thumbnail. Probably the `{0}` method has not been invoked',
            'save()'
        ), InvalidArgumentException::class);

        return Router::url(['_name' => 'thumb', base64_encode(basename($this->target))], $fullBase);
    }
951750
public static function handles($uri)
	{
		$uri = rtrim($uri, '/').'/';

		foreach (static::$bundles as $key => $value)
		{
			if (isset($value['handles']) and starts_with($uri, $value['handles'].'/') or $value['handles'] == '/')
			{
				return $key;
			}
		}

		return DEFAULT_BUNDLE;
	}
55350
public function getThumbnail($originalImagePath, $type)
    {
        if (array_key_exists($type, $this->getTypes())) {
            return preg_replace('#^(.*)\.(' . implode('|', $this->getAllowedExtensions()) . ')$#', '$1-' . $this->getThumbnailPrefix() . '-' . $type . '.$2', $originalImagePath);
        }

        return false;
    }