I have a background upload task that is defined in the following manner:
NSURLSessionUploadTask* task = [session_ uploadTaskWithRequest:request fromFile:[NSURL fileURLWithPath:httpBody]];
I would like to deletehttpBody
once the upload task is finished, which happens in my delegate in this function:
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
{
Q_UNUSED(session);
if (error)
{
reportError(callback, error);
}
else
{
NSMutableData *responseData = self.responsesData[@(task.taskIdentifier)];
if (responseData)
{
NSDictionary *response = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:nil];
if (response)
{
LOG_INFO << [NSString stringWithFormat:@"%@", response];
}
else
{
LOG_INFO << [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
}
[self.responsesData removeObjectForKey:@(task.taskIdentifier)];
}
(*callback)(boost::none);
}
}
I am not sure how to access httpBody
in didCompleteWithError
so I can delete it. How do I do this?