gpt4 book ai didi

ios - 类型 'GTLQueryDrive' 没有成员 'queryForFilesInsertWithObject'

转载 作者:搜寻专家 更新时间:2023-11-01 06:40:22 25 4
gpt4 key购买 nike

我正在用 swift 编写代码。我试图使用以下链接集成谷歌驱动器 https://developers.google.com/drive/ios/quickstart .我使用链接 https://github.com/google/google-api-objectivec-client.git 下载了谷歌客户端库谷歌开发人员指南的第 2 步中提到了这一点。我能够在这里成功运行示例代码。但我必须将文件上传到谷歌驱动器。所以我正在使用 queryForFilesInsertWithObject 方法。但我收到错误消息 GTLQueryDrive' has no member 'queryForFilesInsertWithObject'。我的示例代码如下:

  func uploadPhoto(image: UIImage) {
print("uploading Photo")
let dateFormat = NSDateFormatter()
dateFormat.dateFormat = "'Quickstart Uploaded File ('EEEE MMMM d, YYYY h:mm a, zzz')"

let file = GTLDriveFile() as GTLDriveFile
//file.title = dateFormat.stringFromDate(NSDate())
file.descriptionProperty = "Uploaded from Google Drive IOS"
file.mimeType = "image/png"

let data = UIImagePNGRepresentation(image)
let uploadParameters = GTLUploadParameters(data: data!, MIMEType: file.mimeType)
let query = GTLQueryDrive.queryForFilesInsertWithObject(file, uploadParameters: uploadParameters) as! GTLQueryDrive
//let waitIndicator = self.showWaitIndicator("Uploading To Google Drive")

self.service.executeQuery(query, completionHandler: { (ticket, insertedFile , error) -> Void in
let myFile = insertedFile as? GTLDriveFile

// waitIndicator.dismissWithClickedButtonIndex(0, animated: true)
if error == nil {
print("File ID \(myFile?.identifier)")
self.showAlert("Google Drive", message: "File Saved")
} else {
print("An Error Occurred! \(error)")
self.showAlert("Google Drive", message: "Sorry, an error occurred!")
}

})
}

请帮助我,如果有任何项目可用吗?

最佳答案

使用

let query = GTLQueryDrive.queryForFilesCreateWithObject(file, uploadParameters: uploadParameters) as GTLQueryDrive

关于ios - 类型 'GTLQueryDrive' 没有成员 'queryForFilesInsertWithObject',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36215649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com