Is there any URL google has that contains the raw data for the file? using https://drive.google.com/file/d/FILE_ID
just takes you to a 'share' section of the file... say I have a .js file on GDrive. If you go to their share link, they have a share page. Is there any link to get the raw javascript from the file, as to use in a <script src="google_link_or_whatever">
?

- 361
- 1
- 3
- 9
-
Does this help? http://googleappsdeveloper.blogspot.nl/2012/11/announcing-google-drive-site-publishing.html – Dave Morrissey Jul 18 '14 at 23:06
-
@DaveMorrissey It probably would, thanks, but i'm trying to stay away from APIs. :D – parzivail Jul 18 '14 at 23:13
-
possible duplicate of [Google Apps Script How to link to JS or CSS file on Google Drive](http://stackoverflow.com/questions/15110264/google-apps-script-how-to-link-to-js-or-css-file-on-google-drive) – Fraser Jul 21 '15 at 10:31
3 Answers
First, go to the sharing settings for your document and choose "Anyone with a link." It will generate a link in the format https://drive.google.com/file/d/XXX/view?usp=sharing
.
Now you can use the following URL format: https://drive.google.com/uc?id=XXX
Note that I'm seeing an HTTP redirect when I do this, so use curl -L
on the command line or otherwise make sure that your HTTP client follows redirect.

- 30,702
- 30
- 134
- 179
-
-
4Append `&confirm=t` if the URL points to a binary that Google Drive cannot scan (for example, a `.tar.gz`). – bishop Mar 03 '22 at 19:14
Sharing link:
https://drive.google.com/file/d/YOUR_FILE_ID/view?usp=sharing
Raw download link:
https://drive.google.com/uc?export=download&id=YOUR_FILE_ID

- 6,279
- 7
- 48
- 77

- 151
- 1
- 2
-
1Worked like a charm! Someone on a [GitHub issue](https://github.com/libretro/RetroArch/issues/11770) was not able to embed his/her images hosted on Google Drive. With this your syntax it works fine. – porg Feb 12 '22 at 18:30
-
Summing this up in a one-liner for convenience: `wget --content-disposition --trust-server-names $(echo $GDRIVE_NAME | sed -e 's#/file/d/\([^/]\+\)/.*$#/uc?export=download\&id=\1#')` – Valer Aug 09 '22 at 09:56
NOTE - THIS WAS THE SOLUTION BUT IT NO LONGER WORKS - SEE COMMENT BY @Bobby Fritze below
No API's and no JS necessary. Confirmed now working on latest version of Drive. Great workaround for if your server doesn't use https but a vendor plugin demands https to call in a CSS or other file:
- On the folder with your intended file (e.g. FILE.css), hit Sharing Settings, then Advanced, then select "Public on the web - Anyone on the Internet can find and view."
- In the URL bar (or share link), copy everything after the drive.google.com/drive/u/0/folders/
- Use that ID to replace the XX-XXXXXXXXXXXXX in: http://googledrive.com/host/XX-XXXXXXXXXXXXX/FILE.css
- Navigate to the appended URL in Step 3 and you will now see your raw data.
My use case below:
<script type="text/javascript">
var vsDisableResize = false;
var vsCssUrl = 'https://cbe7c864b9c1ae8d5be60c7fed3e467334a04d2f.googledrive.com/host/0B9ngkmVbo5T7TDhTTU81M25iNnc/cart.css';
var vsWineryId = '850';
var vsWineListId = '71';
Credit to @chris.huh at: https://productforums.google.com/forum/#!topic/drive/MyD7dgLJaEo

- 3,530
- 1
- 19
- 25

- 182
- 1
- 8
-
1What's this code cbe7c864b9c1ae8d5be60c7fed3e467334a04d2f in your URL? – Mudit Jain Jul 15 '16 at 06:19
-
Each folder you create in Drive will a string after the /folders/ in the Url; (that's the string noted in Step 3). The string you're seeing there is output (in a server-side way idk about), because: http://googledrive.com/host/0BxfRpcEmqYiJRjlJUXozTm80ZlE/why.txt will point you to a static Url of the raw data – Bobby Fritze Jul 21 '16 at 13:00
-
7EDIT: Sometime around late 2016/early 2017, this method of retrieving files from Google Drive stopped working. – Bobby Fritze Mar 07 '17 at 07:25
-
5The answer provided here worked for me: https://stackoverflow.com/a/26191472/1215260, i.e. set sharing to public as described above and use this URL: https://drive.google.com/uc?id=YOUR_DOCUMENT_ID – jsaven Feb 16 '19 at 08:39