AFHTTPSessionManager *session = [AFHTTPSessionManager manager]; [session POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) { NSData *data = [NSData dataWithContentsOfFile:filePath]; [formData appendPartWithFileData:data name:@"logfile" fileName:filePath.lastPathComponent mimeType:@"text/plain"]; } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable resp) { BOOL result = false; if (resp[@"code"] && [resp[@"code"] intValue] == 0) {
result = true; } if (completion) { completion(result); } } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { if (completion) { completion(false); } }];