問題描述
我正在嘗試從 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!