我正在尝试使用OneDrive iOS SDK在我的应用中集成OneDrive。我设法做了我想要的大部分事情,但我似乎无法弄清楚如何在OneDrive上的文件夹(项目)中上传图像。上传似乎仅在存在现有图像时才有效,我试图上传的图像替换它。
以下是我用来执行此操作的代码:
func uploadDataInFolder(folderToUploadInId: String, data: NSData) {
let uploadRequest = authenticatedOdClient?.drive().items(folderToUploadInId).contentRequest()
uploadRequest?.uploadFromData(data, completion: {
(item, error) -> Void in
if error == nil {
print("uploadSuccesfull in folder \(item.id)")
} else {
print(error)
print("upload unsuccesfull")
}
})
}
答案 0 :(得分:0)
The request as you've constructed it is attempting to modify the binary contents of the folder itself (which doesn't make sense). Try:
items(folderToUploadInId).itemByPath("image.jpg").contentRequest()