从 Google Drive API 获取图像文件 URL

时间:2023-02-10
本文介绍了从 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.

图片网址经过混淆处理,无法检索.您可以做的最好的事情是使用 viewpreview 链接,它们仅在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:Discord.js 静音命令仅发送不正确命令的嵌入 下一篇:(节点:10388)UnhandledPromiseRejectionWarning:TypeError:无法

相关文章

最新文章