Android Question Google Drive API: MD5 hash of files to synchronize

peacemaker

Well-Known Member
Licensed User
SOLVED: added into GoogleDrive class

B4X:
'Get metadata of a file from Google Drive
'        FileID : mandatory id of the File.
'Event: GotFileMetadata
Sub Get_FileMetadata(FileID As String) As ResumableSub
    Dim Job As HttpJob
    Job.Initialize("",Me)
    Job.Download("https://www.googleapis.com/drive/v3/files/" & FileID & "?fields=originalFilename,fileExtension,md5Checksum,size")    '?fields=* - all info
    Job.GetRequest.SetHeader("Authorization", "Bearer " & myAccessToken)
   
    Wait For (Job) JobDone(Job As HttpJob)
    ' ww~~-- ww~~-- ────────────────────
    Dim jg As JSONParser
    If Job.Success Then
        jg.Initialize(Job.GetString)
        Dim m As Map = jg.NextObject
        Log("FileMetadata = " & m)
        'FileMetadata = (MyMap) {kind=drive#file, id=0B8tskcuLtEdsfdfWpaWVkxQjg, name=small.jpg, mimeType=image/jpeg, starred=false, trashed=false, explicitlyTrashed=false, parents=[0AMtskcuLtEqbUk9PVA], spaces=[drive], version=2343254, webContentLink=https://drive.google.com/uc?id=0B8tskcuLtEqbSwefwefaWVkxQjg&export=download, webViewLink=https://drive.google.com/file/d/0B8tskcuLtEqbefwefpaWVkxQjg/view?usp=drivesdk, iconLink=https://drive-thirdparty.googleusercontent.com/16/type/image/jpeg, hasThumbnail=true, thumbnailLink=https://lh3.googleusercontent.com/bIjoNeCnz4xnjNSJoed7xRpcIkUMgq-xNKZQWBczgsgsdgswerxdjFSMVebuqRkjwD1oYRPp3w=s220, thumbnailVersion=1, viewedByMe=true, viewedByMeTime=2018-11-13T11:16:47.829Z, createdTime=2015-12-14T11:24:12.450Z, modifiedTime=2015-12-14T11:30:23.801Z, modifiedByMeTime=2015-12-14T11:24:12.450Z, modifiedByMe=true, owners=[{kind=drive#user, displayName=Name Family, me=true, permissionId=0675342348003739652, emailAddress=email@gmail.com}], lastModifyingUser={kind=drive#user, displayName=Name Family, me=true, permissionId=06758987708003739652, emailAddress=email@gmail.com}, shared=true, ownedByMe=true, capabilities={canAddChildren=false, canChangeCopyRequiresWriterPermission=true, canChangeViewersCanCopyContent=true, canComment=true, canCopy=true, canDelete=true, canDownload=true, canEdit=true, canListChildren=false, canMoveItemIntoTeamDrive=true, canMoveItemOutOfDrive=true, canReadRevisions=true, canRemoveChildren=false, canRename=true, canShare=true, canTrash=true, canUntrash=true}, viewersCanCopyContent=true, copyRequiresWriterPermission=false, writersCanShare=true, permissions=[{kind=drive#permission, id=0543833340839929, type=user, emailAddress=www@gmail.com, role=reader, displayName=iger, photoLink=https://lh3.googleusercontent.com/-HTLO3R9PSAE/AAAAAAAAAAI/AAAAAAAAAEQ/eIxJMboKWYI/s64/photo.jpg, deleted=false}, {kind=drive#permission, id=anyoneWithLink, type=anyone, role=reader, allowFileDiscovery=false}, {kind=drive#permission, id=06758987708003739652, type=user, emailAddress=email@gmail.com, role=owner, displayName=Name Family, deleted=false}], permissionIds=[05438986270040839929, anyoneWithLink, 06758987708003739652], originalFilename=small.jpg, fullFileExtension=jpg, fileExtension=jpg, md5Checksum=3289f8e5d5a31f0fe15088ae6ef086f8, size=166030, quotaBytesUsed=166030, headRevisionId=0B8tskcuLtEqbTFgwZW80Sk5YUC9ab2tvc2hNOEMvVkFuVUU4PQ, imageMediaMetadata={width=1200, height=2132, rotation=0, time=2015:12:14 14:23:30, cameraMake=Xiaomi, cameraModel=Redmi Note 2, exposureTime=0.029996, aperture=2.2, flashUsed=false, focalLength=3.5, isoSpeed=644, meteringMode=CenterWeightedAverage, exposureMode=Auto, colorSpace=sRGB, whiteBalance=Auto, exposureBias=0.0}, isAppAuthorized=false}
        CallSubDelayed2(evModule, evName & "_GotFileMetadata", m)
    Else
        Dim m As Map
        m.Initialize
        m.Put("error", Job.ErrorMessage)
        Log("Job.ErrorMessage=" & Job.ErrorMessage)
        CallSubDelayed2(evModule, evName & "_GotFileMetadata", m)
    End If
   
    Job.Release
    Return Null
End Sub
 
Top