GDrive文件夹创建

时间:2018-09-10 11:13:29

标签: ios swift google-drive-api

如何在Swift iOS的GDrive中创建文件夹? Google登录成功,但无法创建文件夹。我遇到错误-

  

“发生错误:错误Domain = com.google.GTLRErrorObjectDomain代码= 401“需要登录” UserInfo = {GTLRStructuredError = GTLRErrorObject 0x600000054730:{消息:“需要登录”错误:[1]代码:401},NSLocalizedDescription =需要登录}   (lldb)“。

请帮助。

这是我正在使用的代码。

let metadata = GTLRDrive_File()
metadata.name = "Sample"
metadata.mimeType = "application/vnd.google-apps.folder"
let query = GTLRDriveQuery_FilesCreate.query(withObject: metadata, uploadParameters: nil)
query.fields = "id"
let driveService = GTLRDriveService()
driveService.apiKey = "XXXXXXXXXXXXXXX"
driveService.executeQuery(query, completionHandler: { ticket, file, error in
    if error == nil {

    } else {
        if let anError = error {
            print("An error occurred: \(anError)")
        }
    }
})

0 个答案:

没有答案