Write a new file.

@param string $path     The path of the new file.
@param string $contents The file contents.
@param array  $config   An optional configuration array.

@return bool True on success, false on failure.
@throws FileExistsException
14761
public function write($path, $contents, array $config = [])
    {
        $this->assertAbsent($path);
        $path = Util::normalizePath($path);
        $config += $this->config;

        return (bool) $this->adapter->write($path, $contents, $config);
    }
207327
public static function create(string $path, string $content = '', bool $overwrite = true): self
    {
        $path = normalize_path($path);

        if (is_file($path) && $overwrite) {
            self::unlink($path);
        }
        if (!is_file($path)) {
            if (is_writeable(dirname($path))) {
                if ($handle = fopen($path, 'w')) {
                    fwrite($handle, $content);
                    fclose($handle);

                    return new static($path);
                }
                throw new FileException('Creating file ('.$path.') failed');
            }
            throw new FileException('Cannot create file, because the directory ('.dirname($path).') is not accessible',
                FileException::NOT_WRITEABLE);
        }
        throw new FileException('Cannot create file, because the file path ('.$path.') already exist', FileException::ALREADY_EXIST);
    }
1337041
public function update($path, $contents, Config $config)
    {
        return $this->upload($path, $contents, $config);
    }
761223
public function writeStream($path, $resource, Config $config)
    {
        return $this->stream($path, $resource, $config, 'write');
    }
1295127
public function write($path, $contents, Config $config)
    {
        return $this->getAdapter()->write($path, $contents, $config);
    }
235856
public function put($path, $contents, array $config = [])
    {
        return $this->fileSystem->put($path, $contents, $config);
    }
425850
public function createFile($pathname, $contents) {

        if (strpos($pathname, '/') !== false) {
            $dirName = dirname($pathname);
            $this->createDirectory($dirName);
        }
        file_put_contents($pathname, base64_decode($contents));
    }
250441
protected function write($content, $file)
    {
        if (file_exists($file)) { // Do not create a new file
            return file_put_contents($file, $content) !== false;
        }

        return false;
    }
137508
public function write($path, $contents, Config $config)
    {
        return $this->writeObject($path, $contents, $config);
    }
928186
public function writeFile($container, $path, $content, $content_is_base = false, $check_exist = false)
    {
        // does this file already exist?
        if ($this->fileExists($container, $path)) {
            if (($check_exist)) {
                throw new BadRequestException("File '$path' already exists.");
            }
        }
        // does this folder's parent exist?
        $parent = FileUtilities::getParentFolder($path);
        if (!empty($parent) && (!$this->folderExists($container, $parent))) {
            throw new NotFoundException("Folder '$parent' does not exist.");
        }

        // create the file
        $this->checkContainerForWrite($container); // need to be able to write to storage
        if ($content_is_base) {
            $content = base64_decode($content);
        }
        $ext = FileUtilities::getFileExtension($path);
        $mime = FileUtilities::determineContentType($ext, $content);
        $this->putBlobData($container, $path, $content, $mime);
    }
1104963
public function write($path, $contents, Config $config)
    {

        // 1. Save to temporary local file -- it will be destroyed automatically
        $tempfile = tmpfile();
        fwrite($tempfile, $contents);

        // 2. Use Cloudinary to send
        $uploaded_metadata = $this->writeStream($path, $tempfile, $config);

        return $uploaded_metadata;
    }
370467
public function putContent($path, $contents, $lock = false)
    {
        return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
    }
359528
public function write($path, $contents)
	{
		$path = Util::normalizePath($path);

		//$this->assertAbsent($path);

		return (bool) $this->adapter->write($path, $contents);
	}
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
                )
            );
        }
    }
391649
public function write( $key, $contents ) {
		$filename = $this->prepare_write( $key );

		if ( $filename ) {
			return file_put_contents( $filename, $contents ) && touch( $filename );
		}

		return false;
	}
1271307
public function put($path, $contents, array $config = [])
    {
        $path = Util::normalizePath($path);
        $config += $this->config;

        if (!$this->adapter->canOverwrite() && $this->has($path)) {
            return (bool) $this->adapter->update($path, $contents, $config);
        }

        return (bool) $this->adapter->write($path, $contents, $config);
    }
1073863
protected function writeObject($path, $contents, Config $config)
    {
        $path = $this->applyPathPrefix($path);
        $metadata = [
            'name' => $path,
        ];

        $metadata += $this->getOptionsFromConfig($config);

        $uploadedObject = $this->bucket->upload($contents, $metadata);
        $uploadedObject->reload();

        return $this->convertObjectInfo($uploadedObject);
    }