简体   繁体   English

Google Drive无需上传文件PHP

[英]Google Drive without Uploading Files PHP

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

@yazan I don't think that is the correct answer. @yazan我认为这不是正确的答案。

Your question is can you use the API to open a remote file. 您的问题是您可以使用API打开远程文件吗? 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. 这很可能就是您想要的,但这不是您的问题,即API 打开远程文件,而是将Drive Web UI的用户重定向到您的应用程序。

Found the answer: Creating Google Drive shortcuts to external files 找到了答案:为外部文件创建Google云端硬盘快捷方式

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. 如果出于任何原因需要将文件或类似文件的资源存储在云端硬盘之外,则可以使用快捷方式将其仍列在Google云端硬盘中。

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. 与常规文件不同,快捷方式不包含任何内容,并且在同步到桌面时,快捷方式在用户浏览器中以URL的形式打开。 Synced shortcut files are assigned the .glink extension. 同步的快捷方式文件分配有.glink扩展名。

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 或参考以下有关JAVA和python的内容: https : //developers.google.com/drive/integrate-create#create_a_shortcut_to_a_file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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