Get blob

@param  string $container     Container name
@param  string $name          Blob name
@param  string $localFileName Local file name to store downloaded blob

@throws DfException
@throws \Exception
770833
public function getBlobAsFile($container = '', $name = '', $localFileName = null)
    {
        $this->checkConnection();
        try {
            /** @var Container $container */
            $container = $this->blobConn->getContainer($container);
            if (empty($container)) {
                throw new \Exception("No container named '$container'");
            }

            $obj = $container->DataObject($name);

            if (!$obj->SaveToFilename($localFileName)) {
                throw new \Exception('');
            }
        } catch (\Exception $ex) {
            static::handleGuzzleException($ex);
            throw new DfException("Failed to retrieve blob '$name': " . $ex->getMessage());
        }
    }
972610
public function get($name)
    {
        $this->initialize();

        if (!isset($this->parameters[$name]) && !array_key_exists($name, $this->parameters)) {
            if ($this->container) {
                return $this->container->getParameter($name);
            }

            return null;
        }

        return $this->parameters[$name];
    }
185127
function writeFileFromFile($filename, $localFilename, $multicall = false)
    {
        if (!file_exists($localFilename)) {
            throw new InvalidArgumentException('localFilename = ' . print_r($localFilename, true));
        }

        $contents = file_get_contents($localFilename);
        return $this->writeFile($filename, $contents, $multicall);
    }
636853
public function streamBlob($container, $name, $params = [])
    {
        $this->checkConnection();
        try {
            /** @var Container $container */
            $container = $this->blobConn->getContainer($container);
            if (empty($container)) {
                throw new \Exception("No container named '$container'");
            }

            $obj = $container->DataObject($name);

            header('Last-Modified: ' . $obj->getLastModified());
            header('Content-Type: ' . $obj->getContentType());
            header('Content-Length:' . $obj->getContentLength());

            $disposition =
                (isset($params['disposition']) && !empty($params['disposition'])) ? $params['disposition']
                    : 'inline';

            header('Content-Disposition: ' . $disposition . '; filename="' . $name . '";');
            $index = 0;
            $size = (integer)$obj->getContentLength();
            $chunk = \Config::get('df.file_chunk_size');
            ob_clean();

            while ($index < $size) {
                $header = ['Range' => 'bytes=' . $index . '-' . ($index + $chunk - 1)];
                /** @var \Guzzle\Http\Message\RequestInterface $result */
                $request = $container->getService()->getClient()->get($obj->getUrl(), $header);
                /** @var \Guzzle\Http\Message\Response $result */
                $result = $request->send();
                $length = $result->getContentLength();
                $index += $length;
                flush();
                echo $result->getBody();
            }
        } catch (\Exception $ex) {
            static::handleGuzzleException($ex);
            if ($ex instanceof ObjFetchError) {
                $code = HttpStatusCodes::HTTP_NOT_FOUND;
                $status_header = "HTTP/1.1 $code";
                header($status_header);
                header('Content-Type: text/html');
                echo 'Failed to stream/download file. File ' . $name . ' was not found. ' . $ex->getMessage();
            } else {
                throw new DfException('Failed to stream blob: ' . $ex->getMessage());
            }
        }
    }
451070
public static function read(ContainerBuilder $container)
    {
        /** @var InputInterface $input */
        $input = $container->get('input');

        $locations = [getcwd(), getcwd().'/.bldr/'];
        if ($input->hasParameterOption('--global')) {
            $locations = array_merge($locations, [getenv('HOME'), getenv('HOME').'/.bldr/']);
        }

        $locator  = new FileLocator($locations);
        $resolver = new LoaderResolver(
            [
                new Loader\YamlFileLoader($container, $locator),
                new Loader\XmlFileLoader($container, $locator),
                new Loader\PhpFileLoader($container, $locator),
                new Loader\IniFileLoader($container, $locator),
                new Loader\JsonFileLoader($container, $locator),
                new Loader\TomlFileLoader($container, $locator)
            ]
        );

        $loader      = new DelegatingLoader($resolver);
        $files       = static::findFiles($input);
        $foundConfig = false;
        foreach ($files as $file) {
            try {
                $loader->load($file);
                $foundConfig = true;
            } catch (\Exception $e) {
                if (get_class($e) !== 'InvalidArgumentException') {
                    throw $e;
                }
            }
        }

        if (!$foundConfig) {
            throw new ConfigurationFileNotFoundException(
                sprintf(
                    "Either couldn't find the configuration file, or couldn't read it. ".
                    "Make sure the extension is valid (%s). Tried: %s",
                    implode(', ', static::$TYPES),
                    implode(', ', $files)
                )
            );
        }
    }
43545
protected function getFileName($name)
    {
        $name = (string) $name;

        try {
            $template = $this->parser->parse($name);
            $file     = $this->locator->locate($template);
        } catch (\Exception $e) {
            throw new \InvalidArgumentException(sprintf('Unable to find template "%s".', $name));
        }

        return $file;
    }
758168
public function get($name) {
        if (!isset($this->services[$name])) throw new ServiceNotFoundException('Service "'.$name.'" not found.');
        try {
            return $this->services[$name]->resolve($factory=false);
        }
        catch (\Exception $ex) {
            throw new ContainerException($ex->getMessage(), $ex->getCode(), $ex);
        }
    }
1052540
private function getFilename($name)
    {
        if (file_exists($name)) {
            return $name;
        }

        [$plugin, $file] = pluginSplit($name);
        foreach ([null, $plugin] as $scope) {
            $paths = $this->getPaths($scope);
            foreach ($paths as $path) {
                $filePath = $path . $file;
                if (is_file($filePath)) {
                    return $filePath;
                }

                $filePath = $path . $file . TwigView::EXT;
                if (is_file($filePath)) {
                    return $filePath;
                }
            }
        }

        return false;
    }
944019
public function get($name = null)
    {
        if ($name === null) {
            $name = $this->mainname;
        }
        if (!isset($this->dbs[$name])) {
            throw new Exceptions\StorageNotFound($name);
        }
        return $this->dbs[$name];
    }
48059
private function getProfile($name)
    {
        $profiles = $this->container->getParameter('profiles');
        if (!array_key_exists($name, $profiles)) {
            throw new \Exception(
                sprintf(
                    'There is no profile with the name \'%s\', expecting: (%s)',
                    $name,
                    implode(', ', array_keys($profiles))
                )
            );
        }

        return $profiles[$name];
    }
706875
public static function get(string $name, ...$params) {
        if (AppContainer::isAutoLoad()) return self::getAutoLoad($name, $params);

        $map = self::getInstance();
        if (!$map->containsKey($name)) {
            return null;
        }
        /** @var Node $node */
        $node = $map->getNodeByKey($name);
        if (null === $node) {
            return null;
        }
        return $node->getValue()($params);
    }
962399
public void get(String remoteFileName,
                    File localFile)
        throws IOException,
               ClientException,
               ServerException {
        if (gSession.transferMode == GridFTPSession.MODE_EBLOCK) {
            DataSink sink =
                new FileRandomIO(new RandomAccessFile(localFile, "rw"));
            get(remoteFileName, sink, null);
        } else {
            super.get(remoteFileName, localFile);
        }
    }
1356297
public function getBlobProperties($container, $name)
    {
        $this->checkConnection();
        $name = $this->fixBlobName($name);
        /** @var GetBlobPropertiesResult $result */
        $result = $this->blobConn->getBlobProperties($container, $name);
        $props = $result->getProperties();
        $file = [
            'name'           => $name,
            'last_modified'  => gmdate(static::TIMESTAMP_FORMAT, $props->getLastModified()->getTimestamp()),
            'content_length' => $props->getContentLength(),
            'content_type'   => $props->getContentType()
        ];

        return $file;
    }
746264
private function getFileObject($name, $arrayOffset = null)
    {
        if (!is_null($arrayOffset)) {
            if (isset($this->fileObject[$name]) && $this->isArray($this->fileObject[$name]) && isset($this->fileObject[$name][$arrayOffset]) && $this->isInstanceOf($this->fileObject[$name][$arrayOffset],
                    File::class)
            ) {
                return $this->fileObject[$name][$arrayOffset];
            }
        } else {
            if (isset($this->fileObject[$name]) && $this->isInstanceOf($this->fileObject[$name], File::class)) {
                return $this->fileObject[$name];
            }
        }

        return false;
    }
941288
protected function getContainer($name)
    {
        if (!isset($this->containers[$name])) {
            $this->createContainer($name);
        }

        return $this->containers[$name];
    }
595178
protected function _parseItem(Container $container, $name)
    {
        try {
            $element = $container[$name];
        } catch (\Exception $e) {
            return null;
        }

        if (is_object($element)) {
            if ($element instanceof \Closure) {
                $type  = 'closure';
                $value = '';

            } elseif ($element instanceof Container) {
                $value = $this->_parseContainer($element);
                $type  = is_array($value) ? 'container' : 'class';

            } else {
                $type  = 'class';
                $value = get_class($element);
            }

        } elseif (is_array($element)) {
            $type  = 'array';
            $value = '';

        } elseif (is_string($element)) {
            $type  = 'string';
            $value = $element;

        } elseif (is_int($element)) {
            $type  = 'int';
            $value = $element;

        } elseif (is_float($element)) {
            $type  = 'float';
            $value = $element;

        } elseif (is_bool($element)) {
            $type  = 'bool';
            $value = $element;

        } elseif ($element === null) {
            $type  = 'null';
            $value = '';

        } else {
            $type  = 'unknown';
            $value = gettype($element);
        }

        return array(
            'name'  => $name,
            'type'  => $type,
            'value' => $value,
        );
    }
1312431
public function deleteContainer($container, $force = false)
    {
        $this->checkConnection();
        try {
            /** @var Container $container */
            $container = $this->blobConn->getContainer($container);
            if (empty($container)) {
                throw new \Exception("No container named '$container'");
            }

            if (!$container->Delete()) {
                throw new \Exception('');
            }
        } catch (\Exception $ex) {
            static::handleGuzzleException($ex);
            throw new DfException("Failed to delete container '$container': " . $ex->getMessage());
        }
    }