Skip to content

Commit 579f743

Browse files
authored
Update MsgraphAdapter.php
Added write functionality
1 parent 220cd30 commit 579f743

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/MsgraphAdapter.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ public function __construct(array $config)
4747

4848
public function write($path, $contents, Config $config)
4949
{
50+
$path = '/drives/' . $this->config['drive_id'] . '/root:/' . $path;
51+
52+
$file = $this->graph
53+
->createRequest('PUT', $path . ':/content')
54+
->attachBody($contents)
55+
->setReturnType(Model\DriveItem::class)
56+
->execute()
57+
->getBody();
58+
return [
59+
'type' => 'file',
60+
'path' => $path,
61+
'timestamp' => $file->getLastModifiedDateTime()->getTimestamp(),
62+
'size' => $file->getSize(),
63+
'mimetype' => $file->getFile()->getMimeType(),
64+
'visibility' => 'public',
65+
];
5066
}
5167

5268
public function writeStream($path, $resource, Config $config)

0 commit comments

Comments
 (0)