Q:

Deleting a PFFile from Parse via iOS App

I'm trying to allow users to delete a profile image they previously uploaded. I understand that Parse's SDK does not permit deletion of PFFiles, so I must use the REST API correct? I think perhaps my URL is invalid. Am I supposed to use the name of the file as seen in Parse? In my case, profile images are uploaded as "profilePic-(user's objectId).jpg"
Here is my code:
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()

A:

Try something like this:
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()

More information about the command (including security concerns) can be found in Parse's official documentation.

