I'm trying to export my file to Google Share Drive. I was able to export to my own drive but I have not found any solution for the shared one yet.
Currently, what I have so far for uploading file to my drive are these two functions, one will be a public function that will simplify the interface, and another one will actually upload the file:
public func uploadFile(
_ folderName: String,
filePath: String,
MIMEType: String,
onCompleted: ((String?, Error?) -> ())?) {
search(folderName) { (folderID, error) in
if let ID = folderID {
self.upload(ID, path: filePath, MIMEType: MIMEType, onCompleted: onCompleted)
// if not found, create a new one
} else {
self.createFolder(folderName, onCompleted: { (folderID, error) in
guard let ID = folderID else {
onCompleted?(nil, error)
return
}
self.upload(ID, path: filePath, MIMEType: MIMEType, onCompleted: onCompleted)
})
}
}
}
// upload
private func upload(
_ parentID: String,
path: String,
MIMEType: String,
onCompleted: ((String?, Error?) -> ())?) {
...
}
Now I want to upload my files to a shared Drive and I found there are DriveID and Parent properties from this post but it is Node.js and not so sure how to work with it with iOS.
var fileMetadata = {
name: fileName,
mimeType: mime,
'parents': [
"0AFiiwdVdxetuUk9PVA"
],
'teamDriveId': "0AFiiwdVdxetuUk9PVA"
}
Thank you!