如何从Chrome扩展下载公共Google Drive文件
How to download public Google Drive file from Chrome Extension?
我有一个像这样的公共Google Drive文件:https://docs.google.com/uc?id=0B8G77eDgeMdwMmkwcnA5eUV2M0U&export=下载
我想从Chrome扩展程序下载那个文件。
我已经将这些URL添加到扩展清单中的"permissions"元素中(尝试下载文件时有一些重定向,我尝试将它们全部添加):"https://*.docs.googleusercontent.com/"https://docs.google.com/","http://docs.google.com/","https://accounts.google.com/","https://www.google.com/"
当我尝试下载文件时,Chrome返回此错误:
XMLHttpRequest cannot load https://docs.google.com/nonceSigner?nonce=s35adai1lp052&continue=https://do…Ddownload%26h%3D16653014193614665626&hash=inkfclb76vcru6uuoqkfp274hk5joqk9. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
我似乎已经允许下载有问题的网址。
如果我添加了<all_urls>
权限,则下载成功。
知道我需要添加什么权限吗?提前谢谢。
例如使用wget
并查看报告的重定向,您可以看到最后一个主机类似于:
doc-0c-80-docs.googleusercontent.com
第一部分可能是可变的,URL的主机部分中的通配符只能匹配主机名的整个部分。因此,您应该在匹配模式中添加以下内容:
*.googleusercontent.com
访问驱动器文件至少需要以下条件:
- *://drive.google.com/*
- *://*.googleusercontent.com/*
相关文章:
- 如何确保通过电子邮件发送的html文档中的Google Drive链接不会被识别为附件
- 无法使用API-node.js从Google Drive下载文件
- Google Drive:通过javascript访问webContentLink
- Google Drive SDK JavaScript:上传ppt(x)并将其转换为演示文稿(Google幻灯片)
- Google Drive SDK示例python DrEdit不工作(身份验证时闪烁,编辑器未显示)
- 如何通过Google Drive Javascript OAuth2 API创建Google Sheets文档
- 使用Google Drive和Angularjs时,不允许使用请求标头字段Accept Encoding
- 使用JavaScript的Google Drive:处理文件内容
- JavaScript中的Google Drive API请求
- 如何使用PHP从我自己的网站上的Google Drive获取文件和文件夹列表
- NodeJS - Downloading from Google Drive
- Google Drive是否不再允许从其他网站引用JavaScript文件
- 如何从Chrome扩展下载公共Google Drive文件
- 使用Google Drive Viewer显示通过Google Drive API创建的文件
- JSON数据来自未发布的Google Drive电子表格
- 从Google Drive获取文件并隐藏到Blob
- 更新存储在Google Drive上的文件的内容
- 在 Javascript 中使用 Google Drive 共享链接
- 如何在Javascript(Google Drive API)中保存HTTP请求中的URI
- 使用 Google Drive API v3 (javascript) 创建文件