Write a new file using a stream.

@param string   $path
@param resource $resource
@param Config   $config Config object

@return array|false false on failure file meta data on success
13917
public function writeStream($path, $resource, Config $config)
    {
        return $this->upload($path, $resource, $config);
    }
1143288
public function write($path, $contents, Config $config)
    {
        return $this->update($path, $contents, $config);
    }
634199
public static function write(string $fileName = '', $config = null): bool
    {
        $pathInfo = \pathinfo(static::normalizePath($fileName));
        if (!isset($pathInfo['extension'])) {
            $message = \sprintf(
                'Config file name "%s" is missing an extension and cannot be auto-detected',
                $pathInfo['filename']
            );

            throw new RuntimeException($message);
        }

        $extension = \strtolower($pathInfo['extension']);
        if (!\in_array($extension, static::$allowedExtensions)) {
            $message = \sprintf(
                'Unsupported config file type. Supported extension types are: %s',
                \implode(',', static::$allowedExtensions)
            );

            throw new RuntimeException($message);
        }

        if (!isset(static::$writers[$extension]) || !(static::$writers[$extension] instanceof AbstractWriter)) {
            static::$writers[$extension] = WriterManager::get($extension);
        }

        return static::$writers[$extension]->toFile($fileName, $config);
    }
518531
public function write($path, $contents, Config $config) {
        try {
            $mapping = $this->mapper->get($path);

            $file = null;

            if ($mapping) {
                $volume = $this->client->lookup($mapping['fid']);

                $file = new \stdClass();
                $file->url = $volume->url;
                $file->fid = $mapping['fid'];
            }

            $file = $this->client->upload($contents, basename($path), $file);

            if (!$file) {
                return false;
            }

            $this->mapper->store($path, $file->fid, mimetype_from_filename($path), $file->size);

            return $file->toArray();
        } catch (SeaweedFSException $e) {
            return false;
        }
    }
1283478
public static function fileConfig($resource)
    {
        self::$config = new Config($resource, new ConfigLoader());
        self::$config->load();
        self::$config->configure();
    }
870217
public function updateStream($path, $resource, Config $config)
    {
        return $this->writeObject($path, $resource, $config);
    }
667976
public function write($path, $contents, Config $config)
    {
        $this->recursiveCreateDir(Util::dirname($path));

        $location = $this->applyPathPrefix($path);
        $stream = $this->share->write($location);

        fwrite($stream, $contents);

        if (!fclose($stream)) {
            return false;
        }

        return compact('path', 'contents');
    }
844906
public function updateStream(string $path, $resource, array $config = []): bool
    {
        $path = $this->normalizePath($path);
        $this->assertPresent($path);
        $config = $this->prepareConfig($config);
        $this->rewindStream($resource);

        return $this->getAdapter()->updateStream($path, $resource, $config);
    }
948559
public function updateStream($path, $resource, Config $config)
    {
        return $this->stream($path, $resource, $config, 'update');
    }
1371298
def write_config(config, config_path=CONFIG_PATH):
    
    if not os.path.exists(config_path):
        os.makedirs(os.path.dirname(config_path))
    with open(config_path, 'w', encoding='utf-8') as f:
        config.write(f)
140116
public function writeStream($path, $resource, Config $config)
    {
        $uri = stream_get_meta_data($resource)['uri'];

        $response = $this->cosApi->upload($this->getBucket(), $uri, $path,
            null, null, $config->get('insertOnly', 1));

        $response = $this->normalizeResponse($response);

        if (false !== $response) {
            $this->setContentType($path, stream_get_contents($resource));
        }

        return $response;
    }
739050
public function writeStream($uri, $resource, array $config = [])
    {
        return $this->mount_manager->writeStream($uri, $resource, $config);
    }
1154246
public function update($path, $contents, array $config = []) {
        return $this->getFileSystem()->update($path, $contents, $config);
    }
902421
public function writeStream($path, $resource, Config $config)
    {
        try{
            //获得一个临时文件
            $tmpfname       = FileFunction::getTmpFile();

            file_put_contents($tmpfname, $resource);

            $this->getOss()->uploadFile($this->bucket, $path, $tmpfname, $option = []);

            //删除临时文件
            FileFunction::deleteTmpFile($tmpfname);

            return true;
        }
        catch (OssException $e){

        }
        return false;
    }
357955
protected function writeConfigFile(array $config)
    {
        $dumper = new \Symfony\Component\Yaml\Dumper();
        $yaml = $dumper->dump($config, 4);

        file_put_contents($this->configFilePath, $yaml);
    }
844824
public function write($path, $contents, Config $config)
    {
        $temporaryPath = $this->createTemporaryFile($contents);

        $response = $this->cosApi->upload($this->getBucket(), $temporaryPath, $path,
            null, null, $config->get('insertOnly', 1));

        $response = $this->normalizeResponse($response);

        if (false !== $response) {
            $this->setContentType($path, $contents);
        }

        return $response;
    }
1032394
protected function upload($path, $contents, Config $config)
    {
        $path = $this->applyPathPrefix($path);

        $options = $this->getOptionsFromConfig($config);
        $options['name'] = $path;

        $object = $this->bucket->upload($contents, $options);

        return $this->normaliseObject($object);
    }