From c7d905090ebb64b4ea1d16c08ef39c2eba602ec0 Mon Sep 17 00:00:00 2001 From: Grant Timmerman Date: Thu, 6 Jun 2019 17:31:26 -0400 Subject: [PATCH] fix: Use public image URL rather than Drive See cl/248197520 --- slides/snippets/slides_snippets.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/slides/snippets/slides_snippets.py b/slides/snippets/slides_snippets.py index 32e6b2e..1ef35ad 100644 --- a/slides/snippets/slides_snippets.py +++ b/slides/snippets/slides_snippets.py @@ -134,20 +134,13 @@ def create_textbox_with_text(self, presentation_id, page_id): def create_image(self, presentation_id, page_id, image_file_path, image_mimetype): slides_service = self.service - drive_service = self.drive_service # [START slides_create_image] # Temporarily upload a local image file to Drive, in order to obtain a # URL for the image. Alternatively, you can provide the Slides service # a URL of an already hosted image. - upload = drive_service.files().create( - body={'name': 'My Image File', 'mimeType': image_mimetype}, - media_body=image_file_path).execute() - file_id = upload.get('id') - - # Obtain a URL for the image. - image_url = '%s&access_token=%s' % ( - drive_service.files().get_media( - fileId=file_id).uri, self.credentials.access_token) + # + # We will use an existing image under the variable: IMAGE_URL. + IMAGE_URL = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png' # Create a new image, using the supplied object ID, # with content downloaded from image_url. @@ -160,7 +153,7 @@ def create_image(self, presentation_id, page_id, image_file_path, requests.append({ 'createImage': { 'objectId': image_id, - 'url': image_url, + 'url': IMAGE_URL, 'elementProperties': { 'pageObjectId': page_id, 'size': {