krizalys / onedrive-php-sdk

OneDrive SDK for PHP
BSD 3-Clause "New" or "Revised" License
144 stars 66 forks source link

Question - how to provide my own drive for clients to interact with it? #91

Closed anyulled closed 3 years ago

anyulled commented 3 years ago

I need my application to receive uploaded files from a web form and upload them to my OneDrive unit. I already handle the uploading part and would like to know if it's possible to upload those files from my temporal path to oneDrive

ChrstnMgcn commented 3 years ago

Same here. I've even tried hardcoding the access token values and can't get it to work. I would imagine it should be possible though. Hopefully someone can help out.

krizalys commented 3 years ago

@anyulled @ChrstnMgcn Yes, you can use this library to do it. You can use DriveItemProxy::upload(), it supports both string (eg. direct file contents) and streams (eg. file handles opened from the filesystem.

Here is an example with a file resource: https://github.com/krizalys/onedrive-php-sdk/blob/master/test/functional/Proxy/DriveItemProxyTest.php#L287-L295 - in your case, you'll probably need something like:

$content = fread('/path/to/file', 'rb');
$driveItem->upload('my file', $content);