[英]How to add local image to google docs using Google docs API and Python?
我想使用 google docs API 從我的本地系統在我的 google doc 中添加圖像,但我讀到它只接受來自http servers
的圖像
我嘗試在谷歌驅動器上上傳圖像,然后在我的代碼中使用驅動器圖像 url 但它拋出了一個錯誤。
我不想讓 Internet 從我的本地系統訪問圖像,因為它不安全。
有沒有其他方法可以從我的本地將圖像添加到谷歌文檔?
示例代碼:
{
"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"
}
}
}
}
您可以按照以下步驟操作:
Get-Link
Anyone with the link
的任何人設置為查看者。 並復制文件 ID。 例如: https://drive.google.com/file/d/FILE_ID/view?usp=sharing
"uri":"https://drive.google.com/uc?export=view&id=FILE_ID",
這也可以通過Drive API
上傳文件並更改上傳請求的權限來實現。
有關更多文檔,請參閱以下內容:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.