Kodzvn
Kodzvn

Reputation: 55

Retrieving a raw file URL from the Google Drive API

I am trying to get the image file URL from the Google Drive API. Not the webViewLink or webContentLink.

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.

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.

Also, I said Discord can't follow redirects, but I could potentially do it server-side, if there is a solution that works.

Upvotes: 1

Views: 4304

Answers (3)

Luiz
Luiz

Reputation: 153

Try https://drive.google.com/uc?export=download&id=FILE_ID or https://drive.google.com/uc?export=download&id=FILE_ID&confirm=t to bypass the confirmation message

Upvotes: 2

Rafa Guillermo
Rafa Guillermo

Reputation: 15377

Answer:

This is not possible.

More Information.

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.

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.

View link:

https://drive.google.com/file/d/file-id/view

Preview link:

https://drive.google.com/file/d/file-id/preview

Upvotes: 5

PARO
PARO

Reputation: 155

Have you tried:

https://drive.google.com/uc?id={file-id}

(characters)

Upvotes: 7

Related Questions