Find the same file with md5 in Drive.Files.list



drive.files.list로 쿼리한 결과를 스프레드시트로 출력합니다.
구글 드라이브에 같은 파일을 업로드해서 md5가 같은 걸 확인했습니다.

Deduper Spreadsheet.png


Files: list를 사용해서 'quotaBytesUsed' 속성이 큰 순서로 파일 목록을 만듭니다.


'md5Checksum'이 같으면 같은 파일로 간주해서 다른 스프레드시트에 기록할 생각입니다.


Drive Sheet app을 실행해 보려면 다음을 참고하세요.
https://drive.eojji.com/sheet





Files: list
https://developers.google.com/drive/api/v2/reference/files/list

G Suite Developer
Drive REST v2 참조

Lists the user's files. Try it now or see an example.


This method accepts the q parameter, which is a search query combining one or more search terms. For more information, see the Search for files guide.


Response

If successful, this method returns a response body with the following structure:


{   "kind": "drive#fileList",   "etag": etag,   "selfLink": string,   "nextPageToken": string,   "nextLink": string,   "incompleteSearch": boolean,   "items": [     files Resource   ] }

{   "kind": "drive#fileList",   "etag": etag,   "selfLink": string,   "nextPageToken": string,   "nextLink": string,   "incompleteSearch": boolean,   "items": [     files Resource

{
  "kind": "drive#fileList",
  "etag": etag,
  "selfLink": string,
  "nextPageToken": string,
  "nextLink": string,
  "incompleteSearch": boolean,
  "items": [
    files Resource
  ]
}

여기서 items는 files Resource 객체가 요소인 배열입니다. 

Files

The metadata for a file.

https://developers.google.com/drive/api/v2/reference/files


    for (var i = 0; i < fileLeng; i++) {
      count++;
      var file = files.items[i];
      var fileId = file.id;

      fileCont.push(file.quotaBytesUsed);
      fileCont.push(file.md5Checksum);
      fileCont.push(file.title);
      fileCont.push(file.alternateLink);
      fileCont.push(file.mimeType);
      ... ...


file 객체가 항목인 배열에서 file의 md5Checksum 속성이 같은 file만 추출하는 방법을 고민 중입니다.


댓글

이 블로그의 인기 게시물

Duplicate files, Deduper in Google Drive