[英]How to add local image to google docs using Google docs API and Python?
I want to add images in my google doc from my local system using google docs API but I read that it only accepts images from http servers
我想使用 google docs API 从我的本地系统在我的 google doc 中添加图像,但我读到它只接受来自
http servers
的图像
I tried uploading the image on google drive then used the drive image url in my code but it was throwing an error.我尝试在谷歌驱动器上上传图像,然后在我的代码中使用驱动器图像 url 但它抛出了一个错误。
I don't want to allow the Internet to access the image from my local system as it won't be secure.我不想让 Internet 从我的本地系统访问图像,因为它不安全。
Is there any other way to add images to google docs from my local?有没有其他方法可以从我的本地将图像添加到谷歌文档?
sample code:示例代码:
{
"insertInlineImage": {
"location": {
"segmentId": header_id,
"index": 0
},
"uri": "https://stackoverflow.design/assets/img/logos/so/logo-stackoverflow.png",
# This is a sample image.
"objectSize": {
"width": {
"magnitude": 100,
"unit": "PT"
}
}
}
}
You can follow this steps:您可以按照以下步骤操作:
Get-Link
Get-Link
Anyone with the link
as Viewer.Anyone with the link
的任何人设置为查看者。 and copy the file ID.https://drive.google.com/file/d/FILE_ID/view?usp=sharing
https://drive.google.com/file/d/FILE_ID/view?usp=sharing
"uri":"https://drive.google.com/uc?export=view&id=FILE_ID",
This can also be achievable by uploading the file by Drive API
and changing the permissions on the upload request.这也可以通过
Drive API
上传文件并更改上传请求的权限来实现。
Refer the following for more documentation:有关更多文档,请参阅以下内容:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.