我想使用 google docs API 从我的本地系统在我的 google doc 中添加图像,但我读到它只接受来自http servers
的图像
我试图上传谷歌驱动器上的图像,然后在我的代码中使用驱动器图像 URL,但它抛出一个错误。
我不想让互联网从我的本地系统访问图像,因为它不会是安全的。
有没有其他方法可以从我的本地添加图像到谷歌文档?
示例代码 (taken from Tanaike's solution):
{
"insertInlineImage": {
"location": {
"segmentId": header_id,
"index": 0
},
"uri": "https://stackoverflow.design/ets/img/logos/so/logo-stackoverflow.png",
# This is a sample image.
"objectSize": {
"width": {
"magnitude": 100,
"unit": "PT"
}
}
}
}

您可以按照以下步骤操作:
将映像上载到驱动器。
双击它。然后转到Get-Link
将Anyone with the link
设置为 Viewer。并复制文件 ID。例如:https://drive.google.com/file/d/FILE_ID/view?usp=sharing
转到您的 python 脚本并将其添加为 uri
"uri":"https://drive.google.com/uc?export=view&id=FILE_ID",
运行添加图像的函数。
这也可以通过Drive API
上传文件并更改上传请求的权限来实现。
有关更多文档,请参考以下内容:
Multipart Upload Manage sharing本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(59条)