use driveId
parent
9717e32254
commit
6f2a4c4a40
|
@ -23,7 +23,7 @@ class Googledrive {
|
||||||
$this->scope = urlencode($this->scope);
|
$this->scope = urlencode($this->scope);
|
||||||
//$this->DownurlStrName = '@microsoft.graph.downloadUrl';
|
//$this->DownurlStrName = '@microsoft.graph.downloadUrl';
|
||||||
//$this->ext_api_url = '/me/drive/root';
|
//$this->ext_api_url = '/me/drive/root';
|
||||||
$this->default_drive_id = getConfig('default_drive_id', $tag);
|
$this->driveId = getConfig('driveId', $tag);
|
||||||
$res = $this->get_access_token(getConfig('refresh_token', $tag));
|
$res = $this->get_access_token(getConfig('refresh_token', $tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,7 @@ class Googledrive {
|
||||||
|
|
||||||
public function ext_show_innerenv()
|
public function ext_show_innerenv()
|
||||||
{
|
{
|
||||||
if ($this->default_drive_id!='') return ['default_drive_id'];
|
return ['driveId'];
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function list_files($path = '/')
|
public function list_files($path = '/')
|
||||||
|
@ -103,7 +102,7 @@ class Googledrive {
|
||||||
|
|
||||||
if (!($files = getcache('path_' . $path, $this->disktag))) {
|
if (!($files = getcache('path_' . $path, $this->disktag))) {
|
||||||
//$response = curl('GET', $this->api_url . '/drives', '', ['Authorization' => 'Bearer ' . $this->access_token]);
|
//$response = curl('GET', $this->api_url . '/drives', '', ['Authorization' => 'Bearer ' . $this->access_token]);
|
||||||
//$response = curl('GET', $this->api_url . '/files?fields=*,files(id,name,mimeType,size,modifiedTime,parents,webContentLink,thumbnailLink),nextPageToken' . (($this->default_drive_id!='')?'&driveId=' . $this->default_drive_id . '&corpora=teamDrive&includeItemsFromAllDrives=true&supportsAllDrives=true':''), '', ['Authorization' => 'Bearer ' . $this->access_token]);
|
//$response = curl('GET', $this->api_url . '/files?fields=*,files(id,name,mimeType,size,modifiedTime,parents,webContentLink,thumbnailLink),nextPageToken' . (($this->driveId!='')?'&driveId=' . $this->driveId . '&corpora=teamDrive&includeItemsFromAllDrives=true&supportsAllDrives=true':''), '', ['Authorization' => 'Bearer ' . $this->access_token]);
|
||||||
if ($path == '/' || $path == '') {
|
if ($path == '/' || $path == '') {
|
||||||
$files = $this->fileList();
|
$files = $this->fileList();
|
||||||
//error_log1('root_id' . $files['id']);
|
//error_log1('root_id' . $files['id']);
|
||||||
|
@ -181,15 +180,14 @@ class Googledrive {
|
||||||
//$url .= '?fields=files(*),nextPageToken';
|
//$url .= '?fields=files(*),nextPageToken';
|
||||||
//$url .= '?q=mimeType=\'application/vnd.google-apps.folder\'';
|
//$url .= '?q=mimeType=\'application/vnd.google-apps.folder\'';
|
||||||
if ($parent_file_id!='') {
|
if ($parent_file_id!='') {
|
||||||
$q = ${parent_file_id};
|
$q = $parent_file_id;
|
||||||
} else {
|
} else {
|
||||||
if ($this->default_drive_id!='') $q = $this->default_drive_id;
|
$q = $this->driveId;
|
||||||
else $q = 'root';
|
|
||||||
}
|
}
|
||||||
$q = '\'' . $q . '\' in parents and trashed = false';
|
$q = '\'' . $q . '\' in parents and trashed = false';
|
||||||
$q = urlencode($q);
|
$q = urlencode($q);
|
||||||
$url .= '&q=' . $q;
|
$url .= '&q=' . $q;
|
||||||
if ($this->default_drive_id!='') $url .= '&driveId=' . $this->default_drive_id . '&corpora=teamDrive&includeItemsFromAllDrives=true&supportsAllDrives=true';
|
if ($this->driveId!='root') $url .= '&driveId=' . $this->driveId . '&corpora=teamDrive&includeItemsFromAllDrives=true&supportsAllDrives=true';
|
||||||
|
|
||||||
$header['Authorization'] = 'Bearer ' . $this->access_token;
|
$header['Authorization'] = 'Bearer ' . $this->access_token;
|
||||||
|
|
||||||
|
@ -249,8 +247,7 @@ class Googledrive {
|
||||||
$folder['id'] = $res['id'];
|
$folder['id'] = $res['id'];
|
||||||
}
|
}
|
||||||
if (!$folder['id']) {
|
if (!$folder['id']) {
|
||||||
if ($this->default_drive_id!='') $folder['id'] = $this->default_drive_id;
|
$folder['id'] = $this->driveId;
|
||||||
else $folder['id'] = 'root';
|
|
||||||
}
|
}
|
||||||
$result = $this->createFile_c($folder['id'], $passfilename, $pass);
|
$result = $this->createFile_c($folder['id'], $passfilename, $pass);
|
||||||
}
|
}
|
||||||
|
@ -261,8 +258,7 @@ class Googledrive {
|
||||||
public function Move($file, $folder) {
|
public function Move($file, $folder) {
|
||||||
$nowParentId = $this->list_path($file['path'])['id'];
|
$nowParentId = $this->list_path($file['path'])['id'];
|
||||||
if (!$nowParentId) {
|
if (!$nowParentId) {
|
||||||
if ($this->default_drive_id!='') $nowParentId = $this->default_drive_id;
|
$nowParentId = $this->driveId;
|
||||||
else $nowParentId = 'root';
|
|
||||||
}
|
}
|
||||||
if (!$folder['id']) {
|
if (!$folder['id']) {
|
||||||
$res = $this->list_path($folder['path']);
|
$res = $this->list_path($folder['path']);
|
||||||
|
@ -270,8 +266,7 @@ class Googledrive {
|
||||||
$folder['id'] = $res['id'];
|
$folder['id'] = $res['id'];
|
||||||
}
|
}
|
||||||
if (!$folder['id']) {
|
if (!$folder['id']) {
|
||||||
if ($this->default_drive_id!='') $folder['id'] = $this->default_drive_id;
|
$folder['id'] = $this->driveId;
|
||||||
else $folder['id'] = 'root';
|
|
||||||
}
|
}
|
||||||
$url = $this->api_url . '/files/' . $file['id'] . '?removeParents=' . $nowParentId . '&addParents=' . $folder['id'] . '&supportsAllDrives=true';
|
$url = $this->api_url . '/files/' . $file['id'] . '?removeParents=' . $nowParentId . '&addParents=' . $folder['id'] . '&supportsAllDrives=true';
|
||||||
//$tmp['name'] = $newname;
|
//$tmp['name'] = $newname;
|
||||||
|
@ -323,8 +318,7 @@ class Googledrive {
|
||||||
$parent['id'] = $res['id'];
|
$parent['id'] = $res['id'];
|
||||||
}
|
}
|
||||||
if (!$parent['id']) {
|
if (!$parent['id']) {
|
||||||
if ($this->default_drive_id!='') $parent['id'] = $this->default_drive_id;
|
$parent['id'] = $this->driveId;
|
||||||
else $parent['id'] = 'root';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type=='file') {
|
if ($type=='file') {
|
||||||
|
@ -389,8 +383,7 @@ class Googledrive {
|
||||||
//error_log1('找ID:' . json_encode($res));
|
//error_log1('找ID:' . json_encode($res));
|
||||||
$parentId = $res['id'];
|
$parentId = $res['id'];
|
||||||
if (!$parentId) {
|
if (!$parentId) {
|
||||||
if ($this->default_drive_id!='') $parentId = $this->default_drive_id;
|
$parentId = $this->driveId;
|
||||||
else $parentId = 'root';
|
|
||||||
}
|
}
|
||||||
$tmp['name'] = $_POST['upbigfilename'];
|
$tmp['name'] = $_POST['upbigfilename'];
|
||||||
$tmp['parents'][0] = $parentId;
|
$tmp['parents'][0] = $parentId;
|
||||||
|
@ -503,10 +496,10 @@ class Googledrive {
|
||||||
|
|
||||||
$tmp = null;
|
$tmp = null;
|
||||||
if ($_POST['DriveType']=='Googledrive') {
|
if ($_POST['DriveType']=='Googledrive') {
|
||||||
$tmp['default_drive_id'] = '';
|
$tmp['driveId'] = 'root';
|
||||||
} else {
|
} else {
|
||||||
// 直接是id
|
// 直接是id
|
||||||
$tmp['default_drive_id'] = $_POST['DriveType'];
|
$tmp['driveId'] = $_POST['DriveType'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = setConfigResponse( setConfig($tmp, $this->disktag) );
|
$response = setConfigResponse( setConfig($tmp, $this->disktag) );
|
||||||
|
|
Loading…
Reference in New Issue