Google Drive raw data?
Asked Answered
G

3

26

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">?

Gahl answered 18/7, 2014 at 22:47 Comment(3)
Does this help? googleappsdeveloper.blogspot.nl/2012/11/…Stylobate
@DaveMorrissey It probably would, thanks, but i'm trying to stay away from APIs. :DGahl
possible duplicate of Google Apps Script How to link to JS or CSS file on Google DriveEvapotranspiration
C
4

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:

  1. 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."
  2. In the URL bar (or share link), copy everything after the drive.google.com/drive/u/0/folders/
  3. Use that ID to replace the XX-XXXXXXXXXXXXX in: http://googledrive.com/host/XX-XXXXXXXXXXXXX/FILE.css
  4. 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

Cholula answered 4/3, 2016 at 0:51 Comment(4)
What's this code cbe7c864b9c1ae8d5be60c7fed3e467334a04d2f in your URL?Maxa
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: googledrive.com/host/0BxfRpcEmqYiJRjlJUXozTm80ZlE/why.txt will point you to a static Url of the raw dataCholula
EDIT: Sometime around late 2016/early 2017, this method of retrieving files from Google Drive stopped working.Cholula
The answer provided here worked for me: https://mcmap.net/q/536236/-google-apps-script-how-to-link-to-js-or-css-file-on-google-drive, i.e. set sharing to public as described above and use this URL: drive.google.com/uc?id=YOUR_DOCUMENT_IDZettazeugma
B
32

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.

Biquadratic answered 1/6, 2020 at 17:47 Comment(2)
what should I replace xxx with?Anabolite
Append &confirm=t if the URL points to a binary that Google Drive cannot scan (for example, a .tar.gz).Loveless
D
16

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
Dike answered 26/7, 2021 at 9:28 Comment(2)
Worked like a charm! Someone on a GitHub issue was not able to embed his/her images hosted on Google Drive. With this your syntax it works fine.Tube
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#')Telegraphy
C
4

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:

  1. 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."
  2. In the URL bar (or share link), copy everything after the drive.google.com/drive/u/0/folders/
  3. Use that ID to replace the XX-XXXXXXXXXXXXX in: http://googledrive.com/host/XX-XXXXXXXXXXXXX/FILE.css
  4. 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

Cholula answered 4/3, 2016 at 0:51 Comment(4)
What's this code cbe7c864b9c1ae8d5be60c7fed3e467334a04d2f in your URL?Maxa
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: googledrive.com/host/0BxfRpcEmqYiJRjlJUXozTm80ZlE/why.txt will point you to a static Url of the raw dataCholula
EDIT: Sometime around late 2016/early 2017, this method of retrieving files from Google Drive stopped working.Cholula
The answer provided here worked for me: https://mcmap.net/q/536236/-google-apps-script-how-to-link-to-js-or-css-file-on-google-drive, i.e. set sharing to public as described above and use this URL: drive.google.com/uc?id=YOUR_DOCUMENT_IDZettazeugma

© 2022 - 2024 — McMap. All rights reserved.