Is it possible to add local image to Slide using Google Slides API and Python?

旧时模样 提交于 2020-04-07 07:54:55

问题


I want to create a new slides out of the local images using Python. Unfortunately, I do not see an example to upload a local image, only an image URL via the official documentation.

That's why I'm wondering is it possible to do that at all? If it is I would appreciate any kind of help.

Thank you very much


回答1:


From the official documentation:

https://developers.google.com/slides/how-tos/add-image

If you want to add private or local images to a slide, you'll first need to make them available on a publicly accessible URL. One option is to upload your images to Google Cloud Storage and use signed URLs with a 15 minute TTL. Uploaded images are automatically deleted after 15 minutes.




回答2:


Google requires a publicly accessible URL as mentioned in the docs.

You can either:

  1. upload your file to an Internet-accessible server, or
  2. allow the Internet to access your local system.

I'll describe the 2nd approach a bit because the 1st approach is fairly straight-forward.

To allow Google to access your local file without uploading the file to a server, you can use a local HTTP server and expose it to the Internet using a TCP tunneling service like ngrok:

https://ngrok.com/

You can use any local server. If you don't have one, http-server on NPM is easy to use:

https://www.npmjs.com/package/http-server

I've used the ngrok approach successfully.



来源:https://stackoverflow.com/questions/55230433/is-it-possible-to-add-local-image-to-slide-using-google-slides-api-and-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!