如何在iOS中的Google Drive中获取GTLDriveFile的修改日期?

时间:2016-10-13 15:04:40

标签: swift google-drive-api

我正在我的swift项目中集成谷歌驱动器。
通过谷歌驱动器集成指南集成,但我的项目需要访问所有细节,如修改日期,创建日期等。
但无法找到了 所有这些细节。

使用以下代码:

if let modifiedDate = file.modifiedByMeTime{
    print_debug(modifiedDate)
}

if let modifiedDate = file.sharedWithMeTime{
    print_debug(modifiedDate.milliseconds)                
}

如何在iOS中的Google云端硬盘中获取GTLDriveFile的修改日期?

1 个答案:

答案 0 :(得分:1)

Swift 3

 let query = GTLRDriveQuery_FilesList.query()
   query.pageSize = 100
   query.q = path
    query.fields = "files(id,name,mimeType,modifiedTime,createdTime,fileExtension,size),nextPageToken" 
 // u want to specify what all details want as response.//

    service.executeQuery(query, completionHandler: {(ticket, files, error) in

            if let filesList : GTLRDrive_FileList = files as? GTLRDrive_FileList {

            if let filesShow : [GTLRDrive_File] = filesList.files {
            print("files \(filesShow)")
                    for ArrayList in filesShow {
                    let name = ArrayList.name
                    let mimeType = ArrayList.mimeType
                    let id = ArrayList.identifier
                    let folder = (mimeType as NSString?)?.pathExtension


                    let creationTime = ArrayList.createdTime?.date // modified time
                    let modifiedTime = ArrayList.modifiedTime?.date //createdTime

                    }
            }
         })