Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Wird geladen in …3
×

Hier ansehen

1 von 38 Anzeige

Weitere Verwandte Inhalte

Ähnlich wie google drive (20)

Anzeige

Aktuellste (20)

google drive

  1. 1. Google Drive and the Google Drive SDK Building Drive apps Abdelhalim Lagrid Google Developer Group, Algiers 1
  2. 2. Introduction : One of Cloud google’s products : lunched in 2012 ..known by Google Drive API .
  3. 3. What is Google Drive? Yea, some marketing :) 2222
  4. 4. Access Anywhere Google Drive is everywhere you are -- on the web, in your home, at the office, and on the go. So wherever you are, your stuff is just...there. Ready to go, ready to share. Install it on: PC, Mac, Android, iOS
  5. 5. Store your files in a safe place Things happen. Your phone goes for a swim. Your laptop takes an infinite snooze. No matter what happens to your devices, your files are safely stored in Google Drive.
  6. 6. Powerful search Google Drive can search keywords in your files -- even the text in pictures -- to help you quickly find what you're looking for.
  7. 7. View anything When a coworker shares a file with you, you may not have the supported software on your computer. With Google Drive you can open and view over 35 file types directly in the browser.
  8. 8. Access to a world of apps! Google Drive works with the apps that make you more efficient. Choose from a growing set of productivity applications, integrated right into your Drive.
  9. 9. Google Drive SDK Why integrate with Google Drive?
  10. 10. Drive SDK opportunity Extensive Reach Effortless Integration Put your app in front of millions of users with billions of files Get the best of Google Drive's sharing capabilities, storage capacity and user identity management so you can focus on your app ++
  11. 11. Drive SDK features Drive • Create, Read, List, Manage files through the API • Search, sharing and revisions Drive Web UI • Open files and docs with your app directly from Drive
  12. 12. Integrating with Google Drive Getting Started
  13. 13. Steps for integrating your app w/ Drive Prerequisites: • Create a project in the Google APIs Console • Enable the Drive API • Create OAuth 2.0 credentials Integration steps: • Auth with OAuth 2.0 [& OpenID Connect] • Write code for opening / saving / managing files
  14. 14. OAuth 2.0 Introduction
  15. 15. A cool tool... OAuth 2.0 Playground
  16. 16. Integrating with Google Drive Handling Authorization for Web apps
  17. 17. Python Authorization Using OAuth 2.0 - Redirecting users to the Grant screen decorator = OAuth2Decorator(client_id=settings.CLIENT_ID, client_secret=settings.CLIENT_SECRET, scope=settings.SCOPE, user_agent='we-cloud') class Documents(webapp.RequestHandler): @decorator.oauth_required def get(self): user = users.get_current_user() if user: service = build('drive', 'v2', http=decorator.http())
  18. 18. Integrating with Google Drive Interacting with Drive files
  19. 19. Python Instantiating the Drive service Object # Here is the Drive service service = build('drive', 'v2', http=decorator.http())
  20. 20. Python Creating Folders folder = { 'title': self.request.get('project[name]'), 'mimeType': 'application/vnd.google-apps.folder' } created_folder = service.files().insert(body=folder).execute() projectcollectionid = created_folder['id']
  21. 21. Python Creating Files mimetype = 'application/vnd.google-apps.' + self.request.get('doc[type]') document = { 'title': self.request.get('doc[name]'), 'mimeType': mimetype } if projectcollectionid: document['parents'] = [{'id': projectcollectionid}] created_document = service.files().insert(body=document).execute() resourceid = created_document['id']
  22. 22. Python Sharing Files #Share the file with other members new_permission = { 'value': email, 'type': 'user', 'role': 'writer' } service.permissions().insert(fileId=fileid, body=new_permission).execute()
  23. 23. Python Searching for files def retrieve_all_files(service,query): result = [] page_token = None param = {} param['q'] = "fullText contains '"+ query + "'" param['fields'] = "items(id,parents/id)" while True: try: if page_token: param['pageToken'] = page_token files = service.files().list(**param).execute() result.extend(files['items']) page_token = files.get('nextPageToken') if not page_token: break except errors.HttpError, error:
  24. 24. Integrating with Google Drive Adding the Drive Web-UI Integration
  25. 25. UI Integration - "Create"
  26. 26. UI Integration - "Open with"
  27. 27. Distribution - Chrome Web Store
  28. 28. Steps for adding Drive UI integration Prerequisites: • Create a Chrome Web Store listing (Painful !) • Install the application from the CWS • Enable and configure the Drive SDK in the Google APIs Console Integration steps: • Support OAuth 2.0 server-side flow • Read action and file ID from URL parameter
  29. 29. JSON Passing context on open & create What happens when somebody launches your app from Drive? { "action" : "create", "parentId" : "0ADK06pfg" } { "action" : "open", "ids" : ["0Bz0bd"] } URL https://www.yourapp.com/drive?code=<authorization code>&state=<JSON> Create actions Open actions
  30. 30. Integrating with Google Drive The Google Picker
  31. 31. UI Integration - Embedded file picker
  32. 32. JS Embedding the picker google.setOnLoadCallback(createPicker); google.load('picker', '1'); var view = new google.picker.View(google.picker.ViewId.DOCS); view.setMimeTypes("image/png,image/jpeg,image/jpg"); function createPicker() { picker = new google.picker.PickerBuilder() .enableFeature(google.picker.Feature.MULTISELECT_ENABLED) .setAppId(YOUR_APP_ID) .addView(view) .setCallback(pickerCallback) .build(); picker.setVisible(true);
  33. 33. JS Handling picker selections // A simple callback implementation. function pickerCallback(data) { if (data.action == google.picker.Action.PICKED) { var fileId = data.docs[0].id; alert('The user selected: ' + fileId); } }
  34. 34. Other features
  35. 35. • Resumable upload & download • Indexable text • Search! • Conversions to native Google Documents • Export of native Google Documents in many formats • OCR • Revisions • List installed apps • Copy files, Trash files, Touch files • User Permissions • Shortcuts o Auto-generated MIME type o Contentless Other Features / tips & tricks
  36. 36. <Thank You!> http://developers.google.com/drive h.lagrid@gmail.com

×