Loads the binary file with $binaryFileId.

@param string $binaryFileId

@return \eZ\Publish\Core\IO\Values\BinaryFile|\eZ\Publish\Core\IO\Values\MissingBinaryFile

@throws \eZ\Publish\Core\IO\Exception\InvalidBinaryAbsolutePathException
767259
public function loadBinaryFile($binaryFileId)
    {
        $this->checkBinaryFileId($binaryFileId);

        if ($this->isAbsolutePath($binaryFileId)) {
            throw new InvalidBinaryAbsolutePathException($binaryFileId);
        }

        try {
            $spiBinaryFile = $this->metadataHandler->load($this->getPrefixedUri($binaryFileId));
        } catch (BinaryFileNotFoundException $e) {
            $this->logMissingFile($binaryFileId);

            return new MissingBinaryFile([
                'id' => $binaryFileId,
                'uri' => $this->binarydataHandler->getUri($this->getPrefixedUri($binaryFileId)),
            ]);
        }

        if (!isset($spiBinaryFile->uri)) {
            $spiBinaryFile->uri = $this->binarydataHandler->getUri($spiBinaryFile->id);
        }

        return $this->buildDomainBinaryFileObject($spiBinaryFile);
    }
987122
public function getBinaryData()
    {
        $cmd = CatFileCommand::getInstance($this->getRepository())->content($this->getSubject(), $this->ref);

        return $this->getCaller()->execute($cmd)->getRawOutput();
    }
1058922
public BinaryResponse getBinaryResource() throws IOException {
		buildQueryString();
		buildHeaders();

		connection.setDoOutput(true);
		connection.setRequestMethod("GET");

		return readBinaryResponse();
	}
334198
public static byte[] fromBinaryCollection(Collection<Binary> binaryList) throws IOException {
        try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
             BigEndianBinaryWriter writer = new BigEndianBinaryWriter(baos)) {
            writer.writeInt(binaryList.size());
            for (Binary binary : binaryList) {
                writer.writeInt(binary.length());
                writer.writeBinary(binary);
            }
            return baos.toByteArray();
        }
    }
1322581
public function findBinary($binary, $quiet = false)
    {
        return $this->commandExecutor->findBinary($binary, $quiet = false);
    }
102646
protected function parseFileID($fileID)
    {
        /** @var ParsedFileID $parsedFileID */
        $parsedFileID = $this->getProtectedResolutionStrategy()->parseFileID($fileID);
        return $parsedFileID ? $parsedFileID->getTuple() : null;
    }
235734
public function process(BinaryInterface $binary, array $options = []): BinaryInterface
    {
        $type = mb_strtolower($binary->getMimeType());
        if (!\in_array($type, ['image/jpeg', 'image/jpg'], true)) {
            return $binary;
        }

        $tempDir = \array_key_exists('temp_dir', $options) ? $options['temp_dir'] : $this->tempDir;
        if (false === $input = tempnam($tempDir, 'imagine_jpegoptim')) {
            throw new \RuntimeException(sprintf('Temp file can not be created in "%s".', $tempDir));
        }

        $processArguments = [$this->jpegoptimBin];

        $stripAll = \array_key_exists('strip_all', $options) ? $options['strip_all'] : $this->stripAll;
        if ($stripAll) {
            $processArguments[] = '--strip-all';
        }

        $max = \array_key_exists('max', $options) ? $options['max'] : $this->max;
        if ($max) {
            $processArguments[] = '--max='.$max;
        }

        $progressive = \array_key_exists('progressive', $options) ? $options['progressive'] : $this->progressive;
        if ($progressive) {
            $processArguments[] = '--all-progressive';
        } else {
            $processArguments[] = '--all-normal';
        }

        $processArguments[] = $input;
        if ($binary instanceof FileBinaryInterface) {
            copy($binary->getPath(), $input);
        } else {
            file_put_contents($input, $binary->getContent());
        }

        $proc = new Process($processArguments);
        $proc->run();

        if (false !== mb_strpos($proc->getOutput(), 'ERROR') || 0 !== $proc->getExitCode()) {
            unlink($input);
            throw new ProcessFailedException($proc);
        }

        $result = new Binary(file_get_contents($input), $binary->getMimeType(), $binary->getFormat());

        unlink($input);

        return $result;
    }
1159386
public function getBinaryFiles()
    {
        if (isset($this->raw->{'files-bin'})) {
            $base = $this->getBasePath();
            $files = array();

            foreach ((array) $this->raw->{'files-bin'} as $file) {
                $files[] = new SplFileInfo(
                    $base . DIRECTORY_SEPARATOR . Path::canonical($file)
                );
            }

            return $files;
        }

        return array();
    }
1133362
protected function getFilesystemFor($fileID)
    {
        return $this->applyToFileIDOnFilesystem(
            function (ParsedFileID $parsedFileID, Filesystem $fs) {
                return $fs;
            },
            $fileID
        );
    }
739572
public function store(BinaryInterface $binary, $path, $filter)
    {
        $tmpFile = tmpfile();
        fwrite($tmpFile, $binary->getContent());
        $tmpMetadata = stream_get_meta_data($tmpFile);

        $binaryCreateStruct = $this->ioService->newBinaryCreateStructFromLocalFile($tmpMetadata['uri']);
        $binaryCreateStruct->id = $this->getFilePath($path, $filter);
        $this->ioService->createBinaryFile($binaryCreateStruct);

        fclose($tmpFile);
    }
1132876
public WebSocketInputStream initBinary()
    throws IOException
  {
    if (_binaryIn == null) {
      _binaryIn = new WebSocketInputStream(this);
    }

    _binaryIn.init();

    return _binaryIn;
  }
668140
public static function fromBinary(&$binaryData, &$offsetIndex = 0)
    {
        $parsedObject = new static();
        self::parseIdentifier($binaryData[$offsetIndex], $parsedObject->getType(), $offsetIndex++);
        $contentLength = self::parseContentLength($binaryData, $offsetIndex);
        $startIndex = $offsetIndex;

        $children = [];
        $octetsToRead = $contentLength;
        while ($octetsToRead > 0) {
            $newChild = ASNObject::fromBinary($binaryData, $offsetIndex);
            $octetsToRead -= $newChild->getObjectLength();
            $children[] = $newChild;
        }

        if ($octetsToRead !== 0) {
            throw new ParserException("Sequence length incorrect", $startIndex);
        }

        $parsedObject->addChildren($children);
        $parsedObject->setContentLength($contentLength);

        return $parsedObject;
    }
431266
public function buildBinary($binary)
    {
        $class = $this->modulable->findQualifiedName($binary, 'binaries');

        // If there is a class by that name
        if ($class) {
            return new $class($this->container);
        }

        // Else wrap the command in an AnonymousBinary
        $anonymous = new AnonymousBinary($this->container);
        $anonymous->setBinary($this->bash->which($binary));

        return $anonymous;
    }
984989
public function setBinary(string $bin): Command
    {
        if (!is_file($bin)) {
            throw new \InvalidArgumentException('Binary file not exists: '.$bin, ErrorCodes::FILE_NOT_FOUND);
        }
        if (!is_executable($bin)) {
            throw new \InvalidArgumentException('Binary file is not executable: '.$bin, ErrorCodes::FILE_NOT_EXECUTABLE);
        }
        $this->bin = $bin;
        return $this;
    }
1196447
public static BinaryDocument create(String id, ByteBuf content) {
        return new BinaryDocument(id, 0, content, 0, null);
    }
290580
public function getFileId(): \Psr\Http\Message\UriInterface
    {
        if (!$this->fileId) {
            return new Uri();
        }

        return $this->fileId;
    }
165744
private function createBinaryFileResponse($file)
    {
        $response = new BinaryFileResponse($file);
        $response->headers->addCacheControlDirective('no-store', true);

        return $response;
    }