I am trying to make a POST request for .ts files using NSURLSession. However, what I want to know is, is there a way to do this without converting the .ts files to an NSData object, and without using it inside an NSDictionary? In other words, can I upload a .ts file directly to the intended URL?
Here is the code I am working with:
NSURL *url = [NSURL URLWithString:@"myURL"];
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
request.HTTPMethod = @"POST";
//I don't want to use the following line
NSDictionary *dictionary = @{@"key1": @"value1"};
NSError *error = nil;
//I don't want to use the following line
NSData *data = [NSJSONSerialization dataWithJSONObject:dictionary
options:kNilOptions error:&error];
if (!error) {
NSURLSessionUploadTask *uploadTask = [session uploadTaskWithRequest:request
fromData:data completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
}];
[uploadTask resume];
}
How can I accomplish this?