src/Storage/File/StorableFileFactory.php
public function makeFromRawData($data, $name = null, $mimeType = null)
    {
        $file = new RawStorableFile;

        if ($data instanceof RawContentInterface) {
            $data = $data->content();
        }

        // Guess the mimetype directly from the content
        if (null === $mimeType) {
            $mimeType = $this->mimeTypeHelper->guessMimeTypeForContent($data);
        }

        if (empty($name)) {
            $name = $this->makeRandomName(
                $this->mimeTypeHelper->guessExtensionForMimeType($mimeType)
            );
        }

        $file->setName($name);
        $file->setData($data);
        $file->setMimeType($mimeType);

        return $this->getReturnPreparedFile($file);
    }
public function makeFromRawData($data, $name = null, $mimeType = null)
    {
        $file = new RawStorableFile;

        if ($data instanceof RawContentInterface) {
            $data = $data->content();
        }

        // Guess the mimetype directly from the content
        if (null === $mimeType) {
            $mimeType = $this->mimeTypeHelper->guessMimeTypeForContent($data);
        }

        if (empty($name)) {
            $name = $this->makeRandomName(
                $this->mimeTypeHelper->guessExtensionForMimeType($mimeType)
            );
        }

        $file->setName($name);
        $file->setData($data);
        $file->setMimeType($mimeType);

        return $this->getReturnPreparedFile($file);
    }
public function makeFromRawData ( $ data , $ name = null , $ mimeType = null ) { $ file = new RawStorableFile ; if ( $ data instanceof RawContentInterface ) { $ data = $ data -> content ( ) ; } // Guess the mimetype directly from the content if ( null === $ mimeType ) { $ mimeType = $ this -> mimeTypeHelper -> guessMimeTypeForContent ( $ data ) ; } if ( empty ( $ name ) ) { $ name = $ this -> makeRandomName ( $ this -> mimeTypeHelper -> guessExtensionForMimeType ( $ mimeType ) ) ; } $ file -> setName ( $ name ) ; $ file -> setData ( $ data ) ; $ file -> setMimeType ( $ mimeType ) ; return $ this -> getReturnPreparedFile ( $ file ) ; }
Makes a normalized storable file instance from raw content data.

@param string|RawContentInterface $data
@param string|null                $name
@param string|null                $mimeType
@return StorableFileInterface
Makes a normalized storable file instance from raw content data .