I'm working with the Google API Client for REST
Swift SDK, and I'm trying to parse out modifiedTime
and createdTime
from the API response containing GTLRDrive_File
objects.
But they don't appear to be there? Here's an example of the payload I'm getting from po file
:
GTLRDrive_File 0x60c00084eb20: {
mimeType:"audio/mpeg"
id:"1xt8eqYit3tOrZUeuG9V7_dsq60Iq9xVC"
kind:"drive#file"
name:"Lobo_Loco_-_15_-_Save_the_Bees_ID_817 (2).mp3"
}
What's going on? I wouldn't expect these properties to be optional?
Here's the code I'm using to loop after querying:
if let files = result.files as? [GTLRDrive_File] {
for file in files {
print(file.modifiedTime, file.createdTime)
}
}
(And of course both are nil).
How can I get modified/created dates from a GTLRDrive_File
?
Provided the request (file.list, etc) was successful createdTime
, modifiedTime
which can be found in the Drive File Resource, can be accessed by first accessing 'files' object.
So if you go to Try-it:
Use files(createdTime)
as parameter in the 'field' property and it will return those fields. (Use files.list as sample).
In the iOS SDK, simply:
let query = GTLRDriveQuery_FilesList.query()
query.fields = "files(createdTime,modifiedTime)"
will work.