Skip to content

Commit

Permalink
get disk space size
Browse files Browse the repository at this point in the history
  • Loading branch information
qkqpttgf committed Mar 14, 2021
1 parent 3118222 commit 06db4a7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions disk/Aliyundrive.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,4 +813,19 @@ protected function get_access_token($refresh_token) {
}
return true;
}
public function getDiskSpace() {
if (!($diskSpace = getcache('diskSpace', $this->disktag))) {
$url = $this->api_url . '/databox/get_personal_info';
$header["content-type"] = "application/json; charset=utf-8";
$header['authorization'] = 'Bearer ' . $this->access_token;
$response = curl('POST', $url, '', $header);
//error_log1(json_encode($response));
$res = json_decode($response['body'], true)['personal_space_info'];
$used = size_format($res['used_size']);
$total = size_format($res['total_size']);
$diskSpace = $used . ' / ' . $total;
savecache('diskSpace', $diskSpace, $this->disktag);
}
return $diskSpace;
}
}

0 comments on commit 06db4a7

Please sign in to comment.