get disk space size
parent
82e8d5d0e7
commit
7b51e773f3
|
@ -851,7 +851,7 @@ class Onedrive {
|
|||
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
||||
}
|
||||
$url .= ':/thumbnails/0/medium';
|
||||
$files = json_decode(curl('GET', $url, false, ['Authorization' => 'Bearer ' . $this->access_token])['body'], true);
|
||||
$files = json_decode($this->MSAPI('GET', $url)['body'], true);
|
||||
if (isset($files['url'])) {
|
||||
savecache('thumb_' . $path, $files['url'], $this->disktag);
|
||||
$thumb_url = $files['url'];
|
||||
|
@ -901,6 +901,19 @@ class Onedrive {
|
|||
}
|
||||
return output($response['body'], $response['stat']);
|
||||
}
|
||||
public function getDiskSpace() {
|
||||
if (!($diskSpace = getcache('diskSpace', $this->disktag))) {
|
||||
$url = $this->api_url . $this->ext_api_url;
|
||||
if (substr($url, -5)=='/root') $url = substr($url, 0, -5);
|
||||
else return $url;
|
||||
$response = json_decode($this->MSAPI('GET', $url)['body'], true)['quota'];
|
||||
$used = size_format($response['used']);
|
||||
$total = size_format($response['total']);
|
||||
$diskSpace = $used . ' / ' . $total;
|
||||
savecache('diskSpace', $diskSpace, $this->disktag);
|
||||
}
|
||||
return $diskSpace;
|
||||
}
|
||||
|
||||
protected function MSAPI($method, $path, $data = '')
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue