53

I'm not a programmer, just a regular user of Google Drive. I want to see if the files are uploaded correctly. I go through a whole process in the OAuth 2.0 Playground that lists all files, shows the MD5 checksums but also lots of information per file. If I upload a new file it's hard to search for it and verify its md5 checksum.

Is there an easier way (through an app, maybe?) to show/list MD5 checksums for the uploaded files? I wonder why the Details pane doesn't have it, only lists the file size in bytes.

Alex
  • 1,427
  • 2
  • 13
  • 24
  • 2
    `I wonder why the Details pane doesn't have it, only lists the file size in bytes.` Because 99.99% of users don't have any use for a MD5 hash of an uploaded file. – Zoey Mertes May 04 '14 at 22:14
  • 5
    How else would you know the uploaded file is not corrupted? – Alex May 04 '14 at 22:26
  • One way will be to upload the md5sum along with the file. This can be used by anyone downloading the file. – chandank Jun 24 '14 at 19:59
  • 1
    thanks, but I've already figured out a way to do it and I'm going to add it as a reply. – Alex Jun 26 '14 at 02:10
  • 1
    @ZoeyMertes Which means that for every 1 million users, 100 are going to be inconvenienced... and it seems likely that it's these very users whose time is worth the most and suffer the largest economic cost. All because of the lack of foresight to at least provide a way to show this detail for those who want to see it. – Michael Jul 05 '21 at 18:21
  • _I wonder why the Details pane doesn't have it, only lists the file size in bytes. >>Because 99.99% of users don't have any use for a MD5 hash of an uploaded file._ Nobody has a use for an MD5 hash until they do. – J. Doe Jun 13 '23 at 14:34

5 Answers5

57

edit: NB these instructions have changed slightly for the v3 API

I've figured out a quick way to get the MD5 checksums of the files uploaded and decided to share it here, too. Log into your Google Drive account, then:

Visit: https://developers.google.com/drive/v3/reference/files/list

Scroll down to the Try it! section.

Change "Authorize requests using OAuth 2.0" from OFF to ON by clicking on it, then select:

https://www.googleapis.com/auth/drive.metadata.readonly

and click Authorize.

Choose your account then click Accept.

Fill in the fields field with:

for v2 API:

items(md5Checksum,originalFilename)

for v3 API:

open "Show standard parameters" in GUI to see fields than

files(md5Checksum,originalFilename)

to only get a list of filenames and MD5 checksums.

Click Execute and you'll open a list with all the files uploaded to Google Drive and their MD5 checksums.

Martin Krung
  • 1,098
  • 7
  • 22
Alex
  • 1,427
  • 2
  • 13
  • 24
  • To get the current filename (instead of the original uploaded filename) use `items(md5Checksum,title,owners/emailAddress)` – Rucent88 Oct 02 '15 at 07:10
  • Is this secure? It sounds like we're allowing read/write access to our entire Drive. – Elliott B Feb 20 '16 at 19:30
  • 1
    Yes, it is secured via Oauth2. Note in the answer above he says "and click Authorize". That's three simple words, but behind it is a pretty complex credential check mechanism. If it isn't your file and you don't have the credentials, you will get a 'not authorized' response unless the file owner has made the file public. – labroid Sep 22 '16 at 00:30
  • 4
    @ElliottB you are indeed giving Google read/write access to your Google Drive. imho, they probably already have that :-) – pinoyyid Apr 01 '17 at 18:13
  • 4
    This answer is still valid in 2019. Only some minor changes in the UI. eg: The `fields` field can be located after clicking `Show standard parameters` link and the Try it section is located on the right side of the webpage. – Sourav Ghosh Mar 09 '19 at 16:07
  • 2
    This answer is still valid in 2020, with minor changes. 1) You no longer need to check a box, `Google 0Auth 2.0` is checked by default. 2) For v3 API, you no longer need to select "Show Standard Parameters"; `fields` is found at the bottom of the list without needing to click this link. – mikey Jan 20 '20 at 18:30
  • This is limited though to 100 items. Is there a way to increase the item number, or to "paginate" the result through subsequent queries? – csabahenk Jan 28 '21 at 18:46
  • What exactly does this md5 represent? The MD5 hash of the original file on my hard drive or the MD5 of the file stored in drive? I am asking because I have uploaded using "google backup and sync" and by default it uploads pictures in "high quality"... image dimensions are capped if they are too big and jpeg is re-compressed to "near identical" quality. – Salman A Mar 26 '21 at 13:30
15

API instructions

Google Developers - OAuth 2.0 Playground:

Step 1: Select & authorize APIs:

Step 2: Exchange authorization code for tokens:

  • Click "Exchange authorization code for tokens".

Step 3: Configure request to API:

  • Enter the "Request URI".
  • Click "Send the request".

Request URI instructions

All files in folder

Get specific fields of files in a folder:

https://www.googleapis.com/drive/v3/files?q="folderId"+in+parents&fields=files(md5Checksum,+originalFilename)
//

Replace "folderId" with the folder ID.

You can use &fields=files(*) to get all of the file's fields.

Single file

Get specific fields of a file:

https://www.googleapis.com/drive/v3/files/fileId?fields=md5Checksum,+originalFilename
//

Replace "fileId" with the file ID.

You can use &fields=* to get all of the file's fields.

Parsing the JSON response

  • Open a JavaScript console.
  • Save the object into a variable.
  • Map the object.
  • Copy the result.

Code

var response = {
  "files": [
    {
      "md5Checksum": "0cc175b9c0f1b6a831c399e269772661", 
      "originalFilename": "a.txt"
    }, 
    {
      "md5Checksum": "92eb5ffee6ae2fec3ad71c777531578f", 
      "originalFilename": "b.txt"
    }
  ]
};


var result = response.files.map(function (file) { return (file.md5Checksum + " *" + file.originalFilename); }).join("\r\n");

console.log(result);
copy(result);
XP1
  • 6,910
  • 8
  • 54
  • 61
10

Here are three additional, different ways to list md5 checksums.

  1. Install Google Skicka, a command line tool for Google Drive and run skicka ls -ll / Although the readme file says it's not an official google product it is hosted on google's github account, so I guess it can be trusted.
  2. There is a plugin that lists all files with their checksums in drive's spreadsheet.
  3. Here's my python3 script that I've created for myself. It's mostly copied from google's official examples. You'll need to obtain client_secret.json file and place it in the same directory with the script - here's the instruction how to do it.
JacekM
  • 4,041
  • 1
  • 27
  • 34
3

Based on: Alex's above answer!

  1. Click the link : https://developers.google.com/drive/v3/reference/files/list

  2. Click the Try it now link in the middle.

    ( An active window appears in the middle )

  3. Scroll down the left pane in the active window.

  4. Under fields section on the left pane, fill

    files(md5Checksum,originalFilename)

  5. Now we will limit access scopes :

    (i) leave the Google OAuth 2.0 selected & clear the box against API key.

    (ii) Expand Show scopes under Google OAuth 2.0

    (iii) Clear all the scopes but keep this one selected:

     **https: //www.googleapis.com/auth/drive.metadata.readonly**
    
  6. Now click EXECUTE in blue.

    (A new Google Sign In Window will open)

  7. Use that window to Sign in with the respective google account & click Allow to permit the Google APIs Explorer access files in your google drive.

    It's done! A new window will open with the results in lower right code pane. It will provide the names & md5Checksums for all the files in the respective google drive account.

  8. Click outside of the active window to close the window & close the Google Drive API tab. Now you can sign out of the google account if you want!

0

Combined with XP1 and Alex guides to work in my scenario, to list MD5 for private folders that shared with me

-includeItemsFromAllDrives -includeTeamDriveItems -supportsAllDrives -supportsTeamDrives

Request URI in OAuth 2.0 Playground

https://www.googleapis.com/drive/v3/files?q="folderID"+in+parents&includeItemsFromAllDrives=true&includeTeamDriveItems=true&supportsAllDrives=true&supportsTeamDrives=true&fields=files(md5Checksum%2CoriginalFilename)