do {
// 构建对象
let todo = LCObject(className: "Demo")
// 为属性赋值
try todo.set("TextId", value: "00001")
try todo.set("Title", value: "测试")
if let url = Bundle.main.url(forResource: "photo-1571253318435-f7c4895858b4", withExtension: "jpeg") {
let file = LCFile(payload: .fileURL(fileURL: url))
try todo.set("image", value: file)
}
// 将对象保存到云端
_ = todo.save { result in
switch result {
case .success:
// 成功保存之后,执行其他逻辑
break
case .failure(error: let error):
// 异常处理
print(error)
}
}
} catch {
print(error)
}
图片并保存成功!!
难道必须先保存(上传)File 后才能 赋值给File属性???