src/Proxy/DriveItemProxy.php
public function upload($name, $content, array $options = [])
    {
        $name         = rawurlencode($name);
        $driveLocator = "/drives/{$this->parentReference->driveId}";
        $itemLocator  = "/items/{$this->id}";
        $endpoint     = "$driveLocator$itemLocator:/$name:/content";

        $body = $content instanceof Stream ?
            $content
            : Psr7\stream_for($content);

        $response = $this
            ->graph
            ->createRequest('PUT', $endpoint)
            ->addHeaders($options)
            ->attachBody($body)
            ->execute();

        $status = $response->getStatus();

        if ($status != 200 && $status != 201) {
            throw new \Exception("Unexpected status code produced by 'PUT $endpoint': $status");
        }

        $driveItem = $response->getResponseAsObject(DriveItem::class);

        return new self($this->graph, $driveItem);
    }
public function upload($name, $content, array $options = [])
    {
        $name         = rawurlencode($name);
        $driveLocator = "/drives/{$this->parentReference->driveId}";
        $itemLocator  = "/items/{$this->id}";
        $endpoint     = "$driveLocator$itemLocator:/$name:/content";

        $body = $content instanceof Stream ?
            $content
            : Psr7\stream_for($content);

        $response = $this
            ->graph
            ->createRequest('PUT', $endpoint)
            ->addHeaders($options)
            ->attachBody($body)
            ->execute();

        $status = $response->getStatus();

        if ($status != 200 && $status != 201) {
            throw new \Exception("Unexpected status code produced by 'PUT $endpoint': $status");
        }

        $driveItem = $response->getResponseAsObject(DriveItem::class);

        return new self($this->graph, $driveItem);
    }
public function upload ( $ name , $ content , array $ options = [ ] ) { $ name = rawurlencode ( $ name ) ; $ driveLocator = "/drives/{$this->parentReference->driveId}" ; $ itemLocator = "/items/{$this->id}" ; $ endpoint = "$driveLocator$itemLocator:/$name:/content" ; $ body = $ content instanceof Stream ? $ content : Psr7 \ stream_for ( $ content ) ; $ response = $ this -> graph -> createRequest ( 'PUT' , $ endpoint ) -> addHeaders ( $ options ) -> attachBody ( $ body ) -> execute ( ) ; $ status = $ response -> getStatus ( ) ; if ( $ status != 200 && $ status != 201 ) { throw new \ Exception ( "Unexpected status code produced by 'PUT $endpoint': $status" ) ; } $ driveItem = $ response -> getResponseAsObject ( DriveItem :: class ) ; return new self ( $ this -> graph , $ driveItem ) ; }
Uploads a file under this folder drive item.

@param string $name
The name.
@param string|resource|\GuzzleHttp\Psr7\Stream $content
The content.
@param array $options
The options.

@return DriveItemProxy
The drive item created.

@todo Support name conflict behavior.
@todo Support content type in options.
Uploads a file under this folder drive item .