我想知道是否有可能获取存储在Google Drive中的图像的URI。
我尝试过以下内容:
Drive API:GET https://www.googleapis.com/drive/v2/files/{fileId}
(使用Google Docs batchUpdate ReplaceImageRequest替换图像) uri = file["selfLink"] => "Invalid requests[0].replaceImage: Access to the provided image was forbidden." uri = file["webContentLink"] => "Invalid requests[0].replaceImage: There was a problem retrieving the image. The provided image should be publicly accessible, within size limit, and in supported formats." uri = file["alternateLink"] => (见上文) uri = file["embedLink"] => (见file["webContentLink"])
我正在尝试使用这些属性 - 希望Docs API自动解释drive链接。但这可能只是一厢情愿;因为它当然没有起作用。
我尝试过以下内容:
Drive API:GET https://www.googleapis.com/drive/v2/files/{fileId}
(使用Google Docs batchUpdate ReplaceImageRequest替换图像) uri = file["selfLink"] => "Invalid requests[0].replaceImage: Access to the provided image was forbidden." uri = file["webContentLink"] => "Invalid requests[0].replaceImage: There was a problem retrieving the image. The provided image should be publicly accessible, within size limit, and in supported formats." uri = file["alternateLink"] => (见上文) uri = file["embedLink"] => (见file["webContentLink"])
我正在尝试使用这些属性 - 希望Docs API自动解释drive链接。但这可能只是一厢情愿;因为它当然没有起作用。
ReaplacingImageRequest
,我可以看到我可以给它一个imageObjectId
,它将被提供的 URL 中的 img 替换。这正是我需要做的。然而,文档没有说明如何识别或设置我想要替换的图像的imageObjectId
。我怎么知道(或定义)这个 ID? - Rasmus Pulsdocuments.get
获取完整的文档内容,然后爬取整个文档,匹配我的唯一的alt文本标识符,当我找到该对象时,我可以获取图像对象ID。如果您需要代码示例,请告诉我,然后我可以将其发布到我的博客并发送给您链接。 - Rasmus Puls