Write the contents of a file.

@param  string  $path
@param  string  $contents
@param  bool  $lock
@return int
501383
public function put(string $name, $contents, $lock = false)
  {
    return Filesystem::put(self::url($name), $contents, $lock);
  }
666173
private static function saveToFile($path, $contents)
    {
        $directory = pathinfo($path, PATHINFO_DIRNAME);
        if (!file_exists($directory)) {
            mkdir($directory, 0777, true);
        }
        file_put_contents($path, $contents);
    }
636071
public function write($path, $contents, array $config = [])
    {
        return $this->fileSystem->write($path, $contents, $config);
    }
63329
function write(filepath, contents) {
  return new Promise((resolve, reject)=>{
    fs.writeFile(filepath, contents, (err, response)=>{
      if (err) return reject(err);
      return resolve(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);
    }
137508
public function write($path, $contents, Config $config)
    {
        return $this->writeObject($path, $contents, $config);
    }
1369547
protected function writeContentSafe($path, $content)
    {
        $count = 0;
        $tmpFile = tempnam(dirname($path), basename($path));

        if (@file_put_contents($tmpFile, $content) === false) {
            throw new SystemException(Lang::get('system::lang.file.create_fail', ['name'=>$tmpFile]));
        }

        while (!@rename($tmpFile, $path)) {
            usleep(rand(50000, 200000));

            if ($count++ > 10) {
                throw new SystemException(Lang::get('system::lang.file.create_fail', ['name'=>$path]));
            }
        }

        File::chmod($path);

        /*
         * Compile cached file into bytecode cache
         */
        if (Config::get('cms.forceBytecodeInvalidation', false)) {
            if (function_exists('opcache_invalidate') && ini_get('opcache.enable')) {
                opcache_invalidate($path, true);
            }
            elseif (function_exists('apc_compile_file')) {
                apc_compile_file($path);
            }
        }
    }
379086
public function write(string $contents) : void
    {
        file_put_contents($this->filename, $contents);
        $this->timestamp = time();
    }
810925
private function createFile($path, $contents = '', $mode = 0666)
    {
        if (false === file_put_contents($path, $contents)) {
            throw new RuntimeException(
                sprintf(
                    'The file "%s" could not be written.',
                    $path
                )
            );
        }

        if (!chmod($path, $mode)) {
            throw new RuntimeException(
                sprintf(
                    'The file "%s" could not be chmodded to %o.',
                    $path,
                    $mode
                )
            );
        }
    }
831643
public static function truncate(string $file, bool $lock = false): bool
	{
		return (0 === file_put_contents($file, null, $lock ? LOCK_EX : 0));
	}
625159
public function write($path, $contents, Config $config)
    {
        $overwrite = (bool)$config->get('disable_asserts');

        try {
            return $this->normalizeMetadata($this->api->upload($path, $contents, $overwrite));
        } catch (\Exception $e) {
            return false;
        }
    }
831104
public static function write($file, $data, $lock = false) {
		return file_put_contents($file, $data, $lock ? LOCK_EX : 0);
	}
1194060
public function write($path, $contents, Config $config)
    {
        $options = $this->prepareUploadConfig($config);

        return $this->client->upload($this->getBucket(), $path, $contents, $options);
    }
617427
public function write(string $filename, string $contents): int
    {
        return (int)file_put_contents($filename, $contents);
    }
166750
public function write($path, $contents, Config $config, $isPutFile = false)
    {
        $auth = $this->getAuth();
        $token = $auth->uploadToken($this->bucket, $path);
        $params = $config->get('params', null);
        $mime = $config->get('mime', 'application/octet-stream');
        $checkCrc = $config->get('checkCrc', false);

        $upload_manager = $this->getUploadManager();

        if ($isPutFile) {
        	list($ret, $error) = $upload_manager->putFile($token, $path, $contents, $params, $mime, $checkCrc);
        } else {
        	list($ret, $error) = $upload_manager->put($token, $path, $contents, $params, $mime, $checkCrc);
        }

        if ($error !== null) {
            $this->logQiniuError($error);

            return false;
        } else {
            return $ret;
        }
    }
409069
protected function pathIsLocked($path, $lockMode = null, $openMode = 'r+')
    {
        $lockTestResource = fopen($path, $openMode);
        $lockMode = $lockMode ?: $this->getLockMode() | LOCK_NB;

        if (!flock($lockTestResource, $lockMode)) {
            return true;
        }

        // Remove my created lock.
        flock($lockTestResource, LOCK_UN);

        return false;

    }
981797
public function write($path, $contents, Config $config)
    {
        $object = $this->applyPathPrefix($path);
        $options = $this->getOptions($this->options, $config);

        if (! isset($options[OssClient::OSS_LENGTH])) {
            $options[OssClient::OSS_LENGTH] = Util::contentSize($contents);
        }
        if (! isset($options[OssClient::OSS_CONTENT_TYPE])) {
            $options[OssClient::OSS_CONTENT_TYPE] = Util::guessMimeType($path, $contents);
        }
        try {
            $this->client->putObject($this->bucket, $object, $contents, $options);
        } catch (OssException $e) {
            $this->logErr(__FUNCTION__, $e);
            return false;
        }
        return $this->normalizeResponse($options, $path);
    }