@@ -133,21 +133,16 @@ def create_textbox_with_text(self, presentation_id, page_id):
133133
134134 def create_image (self , presentation_id , page_id , image_file_path ,
135135 image_mimetype ):
136- slides_service = self .service
137136 drive_service = self .drive_service
137+ slides_service = self .service
138138 # [START slides_create_image]
139139 # Temporarily upload a local image file to Drive, in order to obtain a
140140 # URL for the image. Alternatively, you can provide the Slides service
141141 # a URL of an already hosted image.
142- upload = drive_service .files ().create (
143- body = {'name' : 'My Image File' , 'mimeType' : image_mimetype },
144- media_body = image_file_path ).execute ()
145- file_id = upload .get ('id' )
146-
147- # Obtain a URL for the image.
148- image_url = '%s&access_token=%s' % (
149- drive_service .files ().get_media (
150- fileId = file_id ).uri , self .credentials .access_token )
142+ #
143+ # We will use an existing image under the variable: IMAGE_URL.
144+ IMAGE_URL = ('https://www.google.com/images/branding/'
145+ 'googlelogo/2x/googlelogo_color_272x92dp.png' )
151146
152147 # Create a new image, using the supplied object ID,
153148 # with content downloaded from image_url.
@@ -160,7 +155,7 @@ def create_image(self, presentation_id, page_id, image_file_path,
160155 requests .append ({
161156 'createImage' : {
162157 'objectId' : image_id ,
163- 'url' : image_url ,
158+ 'url' : IMAGE_URL ,
164159 'elementProperties' : {
165160 'pageObjectId' : page_id ,
166161 'size' : {
@@ -188,8 +183,6 @@ def create_image(self, presentation_id, page_id, image_file_path,
188183 print ('Created image with ID: {0}' .format (
189184 create_image_response .get ('objectId' )))
190185
191- # Remove the temporary image file from Drive.
192- drive_service .files ().delete (fileId = file_id ).execute ()
193186 # [END slides_create_image]
194187 return response
195188
0 commit comments