我正在尝试允许用户删除之前上传的个人资料图片。我知道Parse的SDK不允许删除PFFiles,所以我必须正确使用REST API吗?我想也许我的网址无效。我应该使用Parse中看到的文件名吗?在我的情况下,个人资料图像上传为“profilePic-(用户的objectId).jpg”
这是我的代码:
let request = NSMutableURLRequest(URL: NSURL(string: "https://api.parse.com/1/files/profilePic-\(currentuser.objectId).jpg")!)
request.HTTPMethod = "DELETE"
request.setValue(appId, forHTTPHeaderField: "X-Parse-Application-Id")
request.setValue(clientKey, forHTTPHeaderField: "X-Parse-Master-Key")
NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
println(response)
}).resume()
答案 0 :(得分:0)
尝试这样的事情:
let request = NSMutableURLRequest(URL: NSURL(string: "https://api.parse.com/1/files/profilePic-\(currentuser.objectId).jpg")!)
request.HTTPMethod = "DELETE"
request.setValue(appId, forHTTPHeaderField: "X-Parse-Application-Id")
request.setValue(clientKey, forHTTPHeaderField: "X-Parse-Master-Key")
let task = NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in
print("Response: \(response)")
})
task!.resume()
有关该命令的更多信息(包括安全问题),请参阅Parse's official documentation。