Google Drive MD5 checksum for files

前端 未结 4 1289
感动是毒
感动是毒 2021-01-30 01:09

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 list

相关标签:
4条回答
  • 2021-01-30 01:25

    API instructions

    Google Developers - OAuth 2.0 Playground:

    • https://developers.google.com/oauthplayground/

    Step 1: Select & authorize APIs:

    • Expand "Drive API v3".
    • Enable "https://www.googleapis.com/auth/drive.metadata.readonly".
    • Click "Authorize APIs".
    • Click "Allow".

    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);
    
    0 讨论(0)
  • 2021-01-30 01:34

    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 讨论(0)
  • 2021-01-30 01:41

    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.
    0 讨论(0)
  • 2021-01-30 01:43

    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.

    0 讨论(0)
提交回复
热议问题