Write stream

@param string $path
@param resouce $resource

@return array|boolean
979517
private function writeStream($path, $resource)
    {
        if (!ftp_fput($this->getConnection(), $path, $resource, $this->transfer_mode)) {
            return false;
        }

        $type = 'file';

        return compact('type', 'path');
    }
440738
private static function writeStream(StreamInterface $stream, $path)
    {
        $dir = dirname($path);

        if (!is_dir($dir)) {
            mkdir($dir, 0777, true);
        }

        $handle = fopen($path, 'wb+');

        if (false === $handle) {
            throw new RuntimeException('Unable to write to designated path');
        }

        $stream->rewind();

        while (!$stream->eof()) {
            fwrite($handle, $stream->read(4096));
        }

        fclose($handle);
    }
1255713
public function create($resource, $resouce_id, $data)
    {
        return $this->client->post("$resource/$resouce_id/comments", [$this->wrapper => $data])->response();
    }
50808
public function updateStream($path, $resource, array $config = []) {
        return $this->getFileSystem()->updateStream($path, $resource, $config);
    }
568810
protected function uploadChunked($path, $resource, $chunkSize = 8000000, $opts = []) {
        $location = $this->applyPathPrefix($path);
        try {
            $fileSize = Util::getStreamSize($resource);
            $localFile = $this->getStreamUri($resource);

            $file = $this->client->uploadChunked($localFile, $location, $fileSize, $chunkSize, $opts);
            return $this->normalizeResponse($file);
        } catch (DropboxClientException $e) {
            return false;
        }
    }
208695
public function stream_open($path, $mode, $options, &$opened_path)
    {
        $opts = stream_context_get_options($this->context);

        if (isset($opts[self::WRAPPER_NAME]['data'])) {
            $data = $opts[self::WRAPPER_NAME]['data'];
        } elseif (isset($opts['horde-combine']['data'])) {
            // @deprecated
            $data = $opts['horde-combine']['data']->getData();
        } else {
            throw new Exception('Use ' . __CLASS__ . '::getStream() to initialize the stream.');
        }

        foreach ($data as $val) {
            if (is_string($val)) {
                $fp = fopen('php://temp', 'r+');
                fwrite($fp, $val);
            } else {
                $fp = $val;
            }

            fseek($fp, 0, SEEK_END);
            $length = ftell($fp);
            rewind($fp);

            $this->_data[] = array(
                'fp' => $fp,
                'l' => $length,
                'p' => 0
            );

            $this->_length += $length;
        }

        return true;
    }
525372
public function writeStream($path, $resource, Config $config)
    {
        $path = pathinfo($path)['filename'];

        $resource_metadata = stream_get_meta_data($resource);
        $uploaded_metadata = Uploader::upload($resource_metadata['uri'], ['public_id' => $path, 'resource_type' => 'auto']);
        
        return $uploaded_metadata;
    }
378875
public function serialize($resource, OutputStream $out): OutputStream
    {
        $out->write($this->xmlSerializerFacade->serializeToXml($resource));
        return $out;
    }
294852
private function readStream($path)
    {
        try {
            $stream = fopen('php://temp', 'w+b');
            $result = ftp_fget($this->getConnection(), $stream, $path, $this->transfer_mode);
            rewind($stream);

            if ($result) {
                return $stream;
            }

            fclose($stream);

            return false;
        } catch (\Exception $exception) {
            throw new ResourceException(sprintf('"%s" not found.', $path));
        }
    }
948559
public function updateStream($path, $resource, Config $config)
    {
        return $this->stream($path, $resource, $config, 'update');
    }
1054182
public function write($path, $resource, Config $config)
    {
        $path = pathinfo($path)['filename'];

        return parent::write($path, $resource, $config);
    }
147802
public function stream_open($path, $mode, $options, &$opened_path)
    {
        $name = $this->_getNamePart($path);
        // If we open the file for writing, just return true. Create the object
        // on fflush call
        if (strpbrk($mode, 'wax')) {
            $this->_objectName = $name;
            $this->_objectBuffer = null;
            $this->_objectSize = 0;
            $this->_position = 0;
            $this->_writeBuffer = true;
            $this->_getOssClient($path);

            return true;
        } else {
            // Otherwise, just see if the file exists or not
            try {
                $info = $this->_getOssClient($path)->getObjectMeta(AliyunOSS::getBucket(), $name);
                if ($info) {
                    $this->_objectName = $name;
                    $this->_objectBuffer = null;
                    $this->_objectSize = (int) $info['content-length'];
                    $this->_position = 0;
                    $this->_writeBuffer = false;

                    return true;
                }
            } catch (\OSS\Core\OssException $e) {
                return false;
            }
        }

        return false;
    }
552488
protected function getWritableStream($path)
    {
        try {
            $handle = $this->getFilesystem()->readStream($path);
            $this->needsCowCheck = true;
        } catch (FileNotFoundException $e) {
            $handle = fopen('php://temp', 'w+b');
            $this->needsFlush = true;
        }

        return $handle;
    }
739050
public function writeStream($uri, $resource, array $config = [])
    {
        return $this->mount_manager->writeStream($uri, $resource, $config);
    }
192956
public function serialize($resource, OutputStream $out): OutputStream
    {
        if (is_object($resource) && method_exists($resource, '__toString')) {
            $out->write((string) $resource);
        } elseif (is_object($resource) || is_array($resource)) {
            $out->write(var_export($resource, true));
        } elseif (is_bool($resource) && $resource) {
            $out->write('true');
        } elseif (is_bool($resource) && !$resource) {
            $out->write('false');
        } else {
            $out->write((string) $resource);
        }

        return $out;
    }
1370859
public static function create($resource = '', array $options = []): StreamInterface
    {
        switch (gettype($resource)) {
            case 'string':
                $stream = fopen('php://temp', 'r+');
                if ($resource !== '') {
                    fwrite($stream, $resource);
                    fseek($stream, 0);
                }
                return new Stream($stream, $options);
            case 'resource':
                return new Stream($resource, $options);
            case 'object':
                if ($resource instanceof StreamInterface) {
                    return $resource;
                } elseif ($resource instanceof \Traversable) {
                    return new IteratorStream($resource, $options);
                } elseif (method_exists($resource, '__toString')) {
                    return static::createStream((string)$resource, $options);
                }
                break;
            case 'NULL':
                return new Stream('php://temp', 'r+');
        }

        throw new InvalidStreamException(
            'Invalid resource type: ' . gettype($resource)
        );
    }
1246832
private function outputStream(): ResourceOutputStream
    {
        if (null === $this->outputStream)
        {
            $this->outputStream = new ResourceOutputStream(self::createStream($this->host, $this->port), 65000);
        }

        return $this->outputStream;
    }