Set the file contents to be sent.

@param string $fileContents
@param string $type
@param string $suggestedFileName
@param string $disposition
@param bool   $ignore_user_abort

@return $this
347318
public function setFileContents($fileContents, $type = self::CONTENT_APP_STREAM, $suggestedFileName = '', $disposition = 'attachment', $ignore_user_abort = false)
    {
        // Set response headers
        $this->setHeaders($type, $suggestedFileName, $disposition, $ignore_user_abort);

        // Set response content
        $this->content = $fileContents;

        return $this;
    }
762478
static function writeFile( $filename,  $fileContent,  $flags=null){
        mkdir(dirname($filename), 0777, true);
        file_put_contents($filename,$fileContent,$flags);
    }
342845
public function put($filename,$content,$type=''){
        $dir         =  dirname($filename);
        if(!is_dir($dir)){
            mkdir($dir,0777,true);
        }
        if(false === file_put_contents($filename,$content)){
            E(L('_STORAGE_WRITE_ERROR_').':'.$filename);
        }else{
            $this->contents[$filename]=$content;
            return true;
        }
    }
331191
public static function putContents($filename, $contents)
    {
        $result = file_put_contents($filename, $contents, \LOCK_EX | \LOCK_NB);
        if ($result === false) {
            throw new \RuntimeException("Cannot write the file: " . $filename);
        }
    }
656896
protected function contentInfoString($type = null, $file = null, $filename = null, $charset = null)
    {
        $data = $this->contentInfoArray($type, $file, $filename, $charset);
        $fields = array();

        foreach ($data as $key => $value) {
            $fields[] = EmailHelper::fold(sprintf('%s: %s', $key, $value));
        }

        return !empty($fields) ? implode("\r\n", $fields)."\r\n\r\n" : null;
    }
1266192
public function goWriteFile(string $filename, string $fileContent, int $flags = 0)
    {
        $this->__filename  = $filename;
        $this->__type      = self::WRITE_FILE;
        $this->__content   = $fileContent;
        $this->__flags     = $flags;

        $this->requestId   = $this->getContext()->getRequestId();
        $requestId         = $this->requestId;

        getInstance()->scheduler->IOCallBack[$this->requestId][] = $this;
        $keys = array_keys(getInstance()->scheduler->IOCallBack[$this->requestId]);
        $this->ioBackKey = array_pop($keys);

        $this->send(function ($filename) use ($requestId) {
            if (empty($this->getContext()) || ($requestId != $this->getContext()->getRequestId())) {
                return;
            }

            if (empty(getInstance()->scheduler->taskMap[$this->requestId])) {
                return;
            }

            $this->result = true;
            $this->ioBack = true;
            $this->nextRun();
        });

        return $this;
    }
207645
public function getContent($type, $name)
    {
        $finder = $this->listFiles($type)->name($name . '.*');

        if (!$finder->count()) {
            throw new Exception(sprintf(
                'No content directory find for type "%s" and name "%s" (in "%s").',
                $type,
                $name,
                $this->directory
            ));
        }

        foreach ($finder as $file) {
            return $this->load($file);
        }

        return null;
    }
688310
public function updateContent($content, $translatedContent = null, $size = null, $type = null)
    {
        if (isset($translatedContent['content' . $content->getId()]) and
            is_array($translatedContent['content' . $content->getId()])
        ) {
            $this->contentManager->updateContent($content, $translatedContent['content' . $content->getId()]);
        }

        if ($size and $type) {
            $type = $this->type->findOneBy(array('name' => $type));
            $contentType = $this->contentType->findOneBy(array('content' => $content, 'type' => $type));
            $contentType->setSize($size);
            $this->manager->persist($contentType);
            $this->manager->flush();
        }
    }
27432
@Override
    public void setContent(final InputStream content, final String contentType,
                           final Collection<URI> checksums, final String originalFileName,
                           final StoragePolicyDecisionPoint storagePolicyDecisionPoint)
            throws InvalidChecksumException {

        // Clear the wrapped binary object prior to setting the content
        wrappedBinary = null;
        // Need to pass the new filename to get the correct implementation.
        getBinary().setContent(content, contentType, checksums, originalFileName,
                storagePolicyDecisionPoint);
    }
661525
public function flush($file_content = null, $type = null)
    {
        if (!empty($file_content)) {
            if (empty($type)) {
                $finfo = new \finfo();
                $type = $finfo->buffer($file_content, FILEINFO_MIME);
            }
            $this->addHeader('Content-Type', $type);
            $this->renderHeaders();
            echo $file_content;
            exit;
        }
        return;
    }
720034
private function addFile(array &$files, string $fieldName, string $filename, string $tmpPath, string $mimeType, bool $err): void
    {
        $data = [
            'type' => $mimeType ?: 'application/octet-stream',
            'name' => $filename,
            'tmp_name' => $tmpPath,
            'error' => $err ? UPLOAD_ERR_CANT_WRITE : UPLOAD_ERR_OK,
            'size' => filesize($tmpPath),
        ];

        $parts = preg_split('|(\[[^\]]*\])|', $fieldName, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
        $count = count($parts);
        if (1 === $count) {
            $files[$fieldName] = $data;
        } else {
            $current = &$files;
            foreach ($parts as $i => $part) {
                if ($part === '[]') {
                    $current[] = $data;
                    continue;
                }

                $trimmedMatch = trim($part, '[]');
                if ($i === $count -1) {
                    $current[$trimmedMatch] = $data;
                } else {
                    $current = &$current[$trimmedMatch];
                }
            }
        }
    }
926928
public function setReadOnly($f)
    {
        if ($f instanceof PhingFile) {
            $strPath = (string) $f->getPath();
            $perms = (int) (@fileperms($strPath) & 0444);

            FileSystem::getFileSystem()->chmod($strPath, $perms);
        } else {
            throw new Exception("IllegalArgumentType: Argument is not File");
        }
    }
114882
public static function filePutContents($filepath, $contents, $message, $usedate = true)
    {
        $suffix = '';

        // Check date
        if ($usedate) {
            $suffix = ' on '.date('l jS \of F Y h:i:s A');
        }

        // Update contents
        $contents = !empty($contents) ? $contents."\n" : $contents;

        // Copy file contents
        file_put_contents($filepath, "/**\n * ".$message.$suffix.".\n */\n\n".$contents);
    }
654913
public void setMimeattach(String strMimeattach, String fileName, String type, String disposition, String contentID, boolean removeAfterSend) throws PageException {
	Resource file = ResourceUtil.toResourceNotExisting(pageContext, strMimeattach);
	pageContext.getConfig().getSecurityManager().checkFileLocation(file);
	if (!file.exists()) throw new ApplicationException("can't attach file " + strMimeattach + ", this file doesn't exist");

	smtp.addAttachment(file, fileName, type, disposition, contentID, removeAfterSend);

    }
269014
public function serveFile($filePath, $mimeType) {
		// if the file exists at the specified path
		if (\file_exists($filePath) && \is_file($filePath)) {
			\header('Content-Type: ' . $mimeType, true);
			\header('Accept-Ranges: none', true);
			\header('Connection: close', true);

			// pipe the actual file contents through PHP
			\readfile($filePath);
		}
		// if the file could not be found
		else {
			throw new \RuntimeException('File `' . $filePath . '` not found');
		}
	}
782022
def set_content_disposition(self,
                                disptype: str,
                                quote_fields: bool=True,
                                **params: Any) -> None:
        """"""
        self._headers[hdrs.CONTENT_DISPOSITION] = content_disposition_header(
            disptype, quote_fields=quote_fields, **params)
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;
  }