Yazan Malkawi
Yazan Malkawi

Reputation: 501

Google Drive without Uploading Files PHP

Is it possible to use Google drive api (with PHP) to open local files (i.e. saved on my server) or that all documents must be uploaded to googe drive?

Upvotes: 0

Views: 463

Answers (2)

pinoyyid
pinoyyid

Reputation: 22306

@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.

Upvotes: 1

Yazan Malkawi
Yazan Malkawi

Reputation: 501

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

Upvotes: 0

Related Questions