src/Provider/FileProvider.php
protected function setFileContents(MediaInterface $media, $contents = null)
    {
        $file = $this->getFilesystem()->get(sprintf('%s/%s', $this->generatePath($media), $media->getProviderReference()), true);
        $metadata = $this->metadata ? $this->metadata->get($media, $file->getName()) : [];

        if ($contents) {
            $file->setContent($contents, $metadata);

            return;
        }

        $binaryContent = $media->getBinaryContent();
        if ($binaryContent instanceof File) {
            $path = $binaryContent->getRealPath() ?: $binaryContent->getPathname();
            $file->setContent(file_get_contents($path), $metadata);

            return;
        }
    }
protected function setFileContents(MediaInterface $media, $contents = null)
    {
        $file = $this->getFilesystem()->get(sprintf('%s/%s', $this->generatePath($media), $media->getProviderReference()), true);
        $metadata = $this->metadata ? $this->metadata->get($media, $file->getName()) : [];

        if ($contents) {
            $file->setContent($contents, $metadata);

            return;
        }

        $binaryContent = $media->getBinaryContent();
        if ($binaryContent instanceof File) {
            $path = $binaryContent->getRealPath() ?: $binaryContent->getPathname();
            $file->setContent(file_get_contents($path), $metadata);

            return;
        }
    }
protected function setFileContents ( MediaInterface $ media , $ contents = null ) { $ file = $ this -> getFilesystem ( ) -> get ( sprintf ( '%s/%s' , $ this -> generatePath ( $ media ) , $ media -> getProviderReference ( ) ) , true ) ; $ metadata = $ this -> metadata ? $ this -> metadata -> get ( $ media , $ file -> getName ( ) ) : [ ] ; if ( $ contents ) { $ file -> setContent ( $ contents , $ metadata ) ; return ; } $ binaryContent = $ media -> getBinaryContent ( ) ; if ( $ binaryContent instanceof File ) { $ path = $ binaryContent -> getRealPath ( ) ? : $ binaryContent -> getPathname ( ) ; $ file -> setContent ( file_get_contents ( $ path ) , $ metadata ) ; return ; } }
Set the file contents for an image.

@param MediaInterface $media
@param string         $contents path to contents, defaults to MediaInterface BinaryContent
Set the file contents for an image .