Google Drive MD5 checksum for files

前端 未结 4 1286
感动是毒
感动是毒 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);
    

提交回复
热议问题