Title pretty much says it all. My app has the URL and password for the file myFile.ext, located at:
https://myserver.com/stuff.cgi?db=mydb
I want to create an NSURL object which, if passed to UIApplication's canOpenURL and openURL methods, will result in appropriate behavior.
Is this possible? If so how? And are there security issues I should be aware of?
EDIT FOR CLARIFICATION:
The following code produces a URL request which, when sent to the server, successfully causes app to download the file. But what I want to do is open it with openURL.
+ (NSMutableURLRequest *) requestForFileNamed: (NSString *) filename {
NSString *url = [NSString stringWithFormat:@"%@&user=%@&getbinfile=%@", serverLocation, username, filename];
NSString *body = [NSString stringWithFormat:@"password=%@", password];
return [XMLRequestBuilder postRequestWithURL:url body:body];
}
XMLRequestBuilder methods:
+ (NSMutableURLRequest *) requestWithURL: (NSString *) url body: (NSString *) body method: (NSString *) method {
NSURL * theURL = [NSURL URLWithString:url];
NSMutableURLRequest * ret = [NSMutableURLRequest requestWithURL:theURL];
[ret setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
[ret setHTTPMethod: method];
[ret setTimeoutInterval:kDefaultTimeoutInterval];
return ret;
}
+ (NSMutableURLRequest *) postRequestWithURL: (NSString *) url body: (NSString *) body {
return [XMLRequestBuilder requestWithURL:url body:body method:@"POST"];
}