Search code examples
phpgoogle-apigoogle-drive-apigoogle-api-php-clientgoogle-drive-realtime-api

Google Drive Api Integration Issue


I'm trying to figure out a workflow for an app that allows users to upload files (Pdfs, Docs etc) and share them with other users in their organization.

The users who need to view the document will not necessarily have permissions to do so through Google Drive, only through the app.

At present, users can upload documents but I want to allow them to link to documents in their Google Drive.

I'm unable to figure out how I would initially go about doing this.

At present, the best idea I have is to gain offline access to their Google Drive account, and retrieve a copy of the document to the server. This doesn't seem like the best idea as having to retrieve a document, save it and show it (ironically using the Google Docs viewer) for every page load would hog server resources.

I could get a copy when the user first adds the document, but then there's no guarantee that it's up to date when someone accesses it several months later.

Is there a correct way to do this?


Solution

  • Check out Drive Platform Best Practices and Performance Tips to help you build high quality Google Drive apps and improve the performance of your application.

    To know any changes, you may want to see the document about Detect Changes and Push Notifications.

    For Google Drive apps that need to keep track of changes to files, the Changes collection provides an efficient way to detect changes to all files, including those that have been shared with a user. The collection works by providing the current state of each file, if and only if the file has changed since a given point in time.

    The Drive API provides push notifications that let you watch for changes to resources. You can use this feature to improve the performance of your application. It allows you to eliminate the extra network and compute costs involved with polling resources to determine if they have changed. Whenever a watched resource changes, the Drive API notifies your application.

    In Manage Revisions, you can always flag to see if there are new revisions created as discussed in the video of Google engineers discussing related tips and tricks.