Getting a image file URL from the Google Drive API(从 Google Drive API 获取图像文件 URL)
问题描述
我正在尝试从 Google Drive API 获取图像文件 URL.不是 webViewLink 或 webContentLink.
I am trying to get the image file URL from the Google Drive API. Not the webViewLink or webContentLink.
背景故事与问题无关,但有助于解释情况.我在 Node.js 中制作了一个 Discord 机器人,而 Discord 不遵循重定向,所以我需要 Discord 可以识别为带有原始图像文件的 URL 的东西.我尝试过其他方法,例如尝试发送 base64 文件,但最好使用图像文件 URL.
The backstory doesn't really matter to the issue but it will help explain the situation. I am making a Discord bot in Node.js and Discord doesn't follow redirects, so I need something that Discord will recognize as a URL with a raw image file. I have tried experimenting with other methods such as trying to send a base64 file, but a image file URL would be best.
我看过另一个 StackOverflow 主题的类似主题,但那里的解决方案无法实现我认为作者的意图.
I have seen the other StackOverflow thread with a similar topic, but the solutions there don't manage to achieve what I think the author was intending.
另外,我说过 Discord 不能跟踪重定向,但如果有可行的解决方案,我可能会在服务器端进行.
Also, I said Discord can't follow redirects, but I could potentially do it server-side, if there is a solution that works.
推荐答案
答案:
这是不可能的.
Google Drive 不是文件托管服务.请记住这一点很重要,因为它并非旨在让您托管文件以在您的网站/应用程序/上使用其他.要正确执行此操作,您应该使用不依赖 Google Drive 环境的专用文件托管服务.
Google Drive is not a file hosting service. This is important to remember because it is not designed to allow you to host files for use on your website/app/other. To do this properly you should use a dedicated file hosting service which doesn't rely on the Google Drive environment.
图片网址经过混淆处理,无法检索.您可以做的最好的事情是使用 view 或 preview 链接,它们仅在 discord UI 中显示缩略图.
The image URL is obfuscated and not retrievable. The best you can do is use the view or preview links which show only a thumbnail in the discord UI.
查看链接:
https://drive.google.com/file/d/file-id/view
预览链接:
https://drive.google.com/file/d/file-id/preview
这篇关于从 Google Drive API 获取图像文件 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 Google Drive API 获取图像文件 URL
基础教程推荐
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
