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
I tried uploading the image on google drive then used the drive image url in my code but it was throwing an error.
I don't want to allow the Internet to access the image from my local system as it won't be secure.
Is there any other way to add images to google docs from my local?
sample code (taken from Tanaike's solution):
{
"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
Anyone with the link
as Viewer. and copy the file ID. For example: 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.
Refer the following for more documentation: