Sets the file to stream.

@param \SplFileInfo|string $file The file to stream
@param string $contentDisposition
@param bool $autoEtag
@param bool $autoLastModified

@return BinaryFileResponse
358426
public function setFile($file, $contentDisposition = null, $autoLastModified = true)
    {
        $this->file = $file;

        if ($autoLastModified) {
            $this->setAutoLastModified();
        }

        if ($contentDisposition) {
            $this->setContentDisposition($contentDisposition);
        }

        return $this;
    }
757240
public function save($file = null)
    {
        //argument 1 must be a file or null
        Argument::i()->test(1, 'string', 'null');
        
        if (is_null($file)) {
            $file = $this->file;
        }
        
        if (is_null($file)) {
            Exception::i()
                ->setMessage(Argument::INVALID_ARGUMENT)
                ->addVariable(1)
                ->addVariable(__CLASS__.'->'.__FUNCTION__)
                ->addVariable('file or null')
                ->addVariable($file)
                ->setTypeLogic()
                ->trigger();
        }
        
        File::i($file)->setData($this->language);
        
        return $this;
    }
1054408
public function setFile($file)
    {
        if (is_string($file)) {
            $file = new PhingFile($file);
        }
        $this->file = $file;
    }
946851
public static function generateFile($file, array $content) {
		$string = static::buildIniString($content);

		return (bool)file_put_contents($file, $string);
	}
156093
public function setFile(File $file = null)
    {
        $this->file = $file;

        if (!empty($file)) {
            $size = @getimagesize($file->getPathname());

            if (is_array($size)) {
                list($this->width, $this->height) = $size;
            }

            $this->refreshUpdatedAt();
        }

        return $this;
    }
359336
public static function forge($file = null, $data = null, $auto_filter = null)
	{
		return new static($file, $data, $auto_filter);
	}
1174244
public function download($file, $name = null, array $headers = array(), $disposition = 'attachment')
	{
		$response = new BinaryFileResponse($file, 200, $headers, true, $disposition);

		if ( ! is_null($name))
		{
			return $response->setContentDisposition($disposition, $name, str_replace('%', '', Str::ascii($name)));
		}

		return $response;
	}
1208157
public function setFile(File $file = null)
    {
        $this->file = $file;
        // Until php7/uploaderbundle 1.7
        if ($file instanceof UploadedFile) {
            $this->setMimeType($file->getMimeType());
            $this->setName($file->getClientOriginalName());
            $this->setSize($file->getSize());
        }
        
        return $this;
    }
808637
public function make($file, $content)
    {
        if ( $this->exists($file))
        {
            throw new FileAlreadyExists;
        }
        $this->put($file, $content);
    }
1080745
public static function setFile($file)
    {
      $rf = realpath($file);
      if (is_file($rf))
        throw new \CatapultApiException("File provided does not exist..");  

      self::$credentials_opts['file'] = realpath($file);
    }
302664
public function filePut($file, $data)
    {
        $file = $this->alias->resolve($file);

        $this->_dirCreate(dirname($file));
        if (file_put_contents($file, $data, LOCK_EX) === false) {
            throw new RuntimeException(['write `:file` file failed: :last_error_message', 'file' => $file]);
        }
    }
351010
protected function setFileToLoad(string $file) : ModularParser
    {
        if (file_exists($file)) {
            $spl = new SplFileInfo($file);
            // check if is as a symlink
            if ($spl->isLink()) {
                throw new InvalidArgumentException(
                    "Argument that given could not as a symlink path.",
                    E_WARNING
                );
            }
            // check if as a file
            if (!$spl->isFile()) {
                throw new InvalidArgumentException(
                    "Argument that given is not a file.",
                    E_WARNING
                );
            }

            if (strtolower($spl->getExtension()) !== 'php') {
                throw new InvalidArgumentException(
                    sprintf(
                        "%s file has invalid extension. ExtensionParser must be as `php`",
                        $this->getName()
                    ),
                    E_WARNING
                );
            }

            $this->file = $spl->getRealPath();
            unset($spl);
            return $this;
        }

        throw new InvalidArgumentException(
            sprintf(
                "Invalid file %s to read.",
                $this->getName()
            ),
            E_WARNING
        );
    }
194564
public function decodeFile($file, $assoc = true, $depth = 512, $options = 0)
    {
        set_error_handler(
                create_function(
                        '$severity, $message, $file, $line', 'throw new ErrorException($message, $severity, $severity, $file, $line);'
                )
        );
        
        try
        {
            $jsonData = file_get_contents($file);
        }
        catch (Exception $e)
        {
            throw new RuntimeException(sprintf($e->getMessage()));
        }

        restore_error_handler();
        
        if(false === $jsonData)
        {
            throw new RuntimeException(sprintf('Unable to get file %s', $file));
        }
        
        return $this->decode($jsonData, $assoc, $depth, $options);
    }
548232
public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) {
        $reference = $this->unpack_reference($storedfile->get_reference());

        $maxcachesize = $this->max_cache_bytes();
        if (empty($maxcachesize)) {
            // Always cache the file, regardless of size.
            $cachefile = true;
        } else {
            // Size available. Only cache if it is under maxcachesize.
            $cachefile = $storedfile->get_filesize() < $maxcachesize;
        }

        if (!$cachefile) {
            \core\session\manager::write_close();
            header('Location: ' . $this->get_file_download_link($reference->url));
            die;
        }

        try {
            $this->import_external_file_contents($storedfile, $this->max_cache_bytes());
            if (!is_array($options)) {
                $options = array();
            }
            $options['sendcachedexternalfile'] = true;
            \core\session\manager::write_close();
            send_stored_file($storedfile, $lifetime, $filter, $forcedownload, $options);
        } catch (moodle_exception $e) {
            // Redirect to Dropbox, it will show the error.
            // Note: We redirect to Dropbox shared link, not to the download link here!
            \core\session\manager::write_close();
            header('Location: ' . $reference->url);
            die;
        }
    }
1141216
public function put($file, $content)
    {
        $file = $this->path($file);

        $dirname = dirname($file);

        $this->makeDirectory($dirname);

        return file_put_contents($file, $content);
    }
88517
public function modify(FileNodeInterface $file, array $options = [])
    {
        if (!$this->canModify($file) || !($file instanceof LocalFileNodeInterface)) {
            throw new InvalidArgumentException(
                "The specified file: '$file' does not implement LocalFileNodeInterface'"
            );
        }

        $file->setEncoding($this->getEncoding($file));

        return $file;
    }
668271
public function setFileBody(string $fileBody, string $contentType='')
  {
    # Clear the normal body
    $this->setBody('');

    # Set content type
    if (!empty($contentType)) {
      $this->setContentType($contentType);
    }

    # Set the filename
    $this->fileBody = $fileBody;

    return $this;
  }