简体   繁体   中英

Google Drive without Uploading Files PHP

是否可以使用Google驱动器api(与PHP)打开本地文件(即保存在我的服务器上),或者必须将所有文档上传到googe驱动器?

@yazan I don't think that is the correct answer.

Your question is can you use the API to open a remote file. If you open the shortcut, you will find there is no content. So shortcut is a bit of a misnomer. If you click on the link using the Web UI, then Drive will fire a file open at your URL and expect you to open a window displaying the file.

This may well be what you want, but it isn't what your question asked, ie the API is not opening the remote file, but rather a user of the Drive web UI is being redirected to your app.

Found the answer: Creating Google Drive shortcuts to external files

Applications can create shortcuts to data stored outside of Drive, in a different data store or cloud storage system. If you need to store files or file-like resources outside of Drive for any reason, shortcuts allow you to still list them in Google Drive.

Shortcuts behave a lot like files. They can be opened and created, indexed in search, and shared with other users. Unlike regular files, shortcuts do not contain any content, and when synced to a desktop are opened as URLs in the user's browser. Synced shortcut files are assigned the .glink extension.

function insertFile($service, $title, $description, $parentId, $mimeType, $filename) {
  $file = new DriveFile();
  $file->setTitle($title);
  $file->setDescription($description);
  $file->setmimeType('application/vnd.google-apps.drive-sdk');
  $createdFile = $service->files->insert($file);
  print "File ID: " . $file->getId();
}

or refer to the following for JAVA and python: https://developers.google.com/drive/integrate-create#create_a_shortcut_to_a_file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM