@deprecated use File->update instead

@param $path
@param $content
@param null $mimeType
@return bool
@throws common_Exception
965752
public function update($path, $content, $mimeType = null)
    {
       return $this->getFile($path)->update($content, $mimeType);
    }
1131000
public function update($path, $contents, Config $config)
    {
        return $this->writeObject($path, $contents, $config);
    }
458395
protected function _filePutContents($path, $content) {
		return $this->query(sprintf('UPDATE %s SET content="%s", size=%d, mtime=%d WHERE id=%d LIMIT 1', $this->tbf, $this->db->real_escape_string($content), strlen($content), time(), $path));
	}
988341
public static function response(
        $file,
        $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT,
        $fileName = null
    ) {
        if (!class_exists('Symfony\\Component\\HttpFoundation\\Response')) {
            throw new MimeTypeException('HttpFoundation component not found, install it.');
        }

        if (
        !in_array(
            $disposition,
            [ResponseHeaderBag::DISPOSITION_INLINE, ResponseHeaderBag::DISPOSITION_ATTACHMENT],
            true
        )
        ) {
            $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT;
        }

        $info = static::info($file);
        $spl = $info->getSplFileObject();

        $response = new Response($spl->fread($spl->getSize()));

        $response->headers->set('Content-Type', $info->getMimeType());
        $disposition = $response->headers->makeDisposition(
            $disposition,
            null === $fileName ? $spl->getFileName() : $fileName
        );
        $response->headers->set('Content-Disposition', $disposition);

        return $response;
    }
399123
public static function write($path, $content)
    {
        if (file_exists($path) && is_file($path) && !is_writable($path)) {
            return new PermissionDeniedException("$path is not writable");
        }

        $directory = dirname($path);

        if (!is_writable($directory)) {
            return new PermissionDeniedException("$directory is not writable");
        }

        file_put_contents($path, $content);
    }
973745
public function addContent(string $cid, string $content, string $name = null, string $mimeType = null): void
    {
        $embed = new ContentEmbed();
        $embed->cid = $cid;
        $embed->content = $content;
        if ($name !== null) {
            $embed->name = $name;
        }
        if ($mimeType !== null) {
            $embed->mimeType = $mimeType;
        }
        $this->set($embed);
    }
771010
protected function setContentType($path, $content)
    {
        $custom_headers = [
            'Content-Type' => Util::guessMimeType($path, $content),
        ];

        return $this->normalizeResponse(
            $this->cosApi->update($this->getBucket(), $path, null, null, $custom_headers)
        );
    }
287143
public function setBody($content, $mime)
	{
		$this->parameters = $content;
		$this->setMime($mime);
		return $this;
	}
1269716
public static function getMimeTypeByContent(string $content)
    {
        if (!\class_exists('\finfo', false)) {
            return null;
        }

        try {
            $finfo = new \finfo(FILEINFO_MIME_TYPE);

            return $finfo->buffer($content) ?: null;
            // @codeCoverageIgnoreStart
        } catch (\ErrorException $e) {
            // This is caused by an array to string conversion error.
            return null;
        }
    }
401166
public function addAttachmentPartFromFile($filePath, $mimeType, $filename = null, $disposition = 'attachment')
    {
        $handle = Psr7\stream_for(fopen($filePath, 'r'));
        if ($filename === null) {
            $filename = basename($filePath);
        }
        $this->addAttachmentPart($handle, $mimeType, $filename, $disposition);
    }
87254
private function createAttachment(
        string $file,
        string $content = null,
        string $contentType = null,
        string $disposition
    ): MimePart {
        $part = new MimePart;
        if ($content === null) {
            $content = @\file_get_contents($file); // @ is escalated to exception
            if ($content === false) {
                throw new FileNotFoundException("Unable to read file '$file'.");
            }
        }

        if (!$contentType) {
            $contentType = MimeType::getMimeTypeByContent($content);
        }

        if (!\strcasecmp($contentType, 'message/rfc822')) { // not allowed for attached files
            $contentType = 'application/octet-stream';
        } elseif (!\strcasecmp($contentType, 'image/svg')) { // Troublesome for some mailers...
            $contentType = 'image/svg+xml';
        }

        $part->setBody($content);
        $part->setContentType($contentType);
        $part->setEncoding(\preg_match('#(multipart|message)/#A', $contentType) ?
            self::ENCODING_8BIT : self::ENCODING_BASE64);
        $part->setHeader('Content-Disposition',
            $disposition . '; filename="' . Strings::fixEncoding(\basename($file)) . '"');

        return $part;
    }
926447
protected function replaceExtension($filename, $mimeType)
    {
        $info = pathinfo($filename);

        switch ($mimeType) {
            case 'image/png':
            case 'image/svg+xml':
                $extension = 'png';
                break;
            case 'image/gif':
                $extension = 'gif';
                break;
            default:
                $extension = 'jpg';
        }

        return $info['filename'] . '.' . $extension;
    }
1349102
public static void saveFile(String path, String content) throws IOException {
        saveFile(path, content, false);
    }
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');
		}
	}
1343318
public function write( $path, $content )
	{
		try {
			$this->fs->put( $path, $content );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
1304055
public function readString($data, $mimeType = null)
    {
        if (null === $mimeType) {
            $mimeType = ContentType::JSON()->primaryMimeType();
        }

        return $this->read($this->uriFactory()->fromData($data, $mimeType), $mimeType);
    }
1302060
public static function fromFile($path, $mimeType, $x = null, $y = null, $width = null, $height = null)
    {
        $imageContent = file_get_contents($path);
        if ($imageContent === false) {
            throw new \RuntimeException('Image file "' . $path . '" could not be read.');
        }

        return self::fromString(
            $imageContent,
            $mimeType,
            $x,
            $y,
            $width,
            $height
        );
    }