ios - 使用 OneDrive iOS SDK 将图片上传到 OneDrive 中的文件夹

标签 ios swift onedrive

我正在尝试使用 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")
        }
    })

}

最佳答案

您构建的请求试图修改文件夹本身的二进制内容(这没有意义)。尝试:

项目(folderToUploadInId).itemByPath("image.jpg").contentRequest()

关于ios - 使用 OneDrive iOS SDK 将图片上传到 OneDrive 中的文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39254242/

相关文章:

ios - 如何从tableViewController中调用uitableviewcell类?

ios - 具有部分匹配值的 Firebase iOS 查询数据

ios - 如何为 UIBezierPath 上的填充颜色变化设置动画?

android-studio - Gradle 错误 : Path is not a readable directory for an Android Project saved in OneDrive

onedrive - 错误 : Public clients can't send a client secret while try to get access token in Onedrive

ios - 你如何在 Swift/iOS 的 UI 测试中遍历元素?

ios - 从 PhoneGap iOS 应用程序中删除文本选择

ios - SKScene 中的 UIPanGestureRecognizer

ios - buttonWithType' 不可用 : use object construction 'UIButton(type:)

c# - 使用 Onedrive SDK/API(或任何 API)保持身份验证