I'm using NMSSH to try to upload a file. I am able to connect and authenticate successfully however the upload hangs and I get the EXC_BAD_ACCESS error on the uploadFile() function call.
I know that it usually means that I'm trying to access an object that doesn't exist but I tried using the Zombies profiler and I could see anything that stood out. In addition, I've implemented the didDisconnectWithError() and didReadError() functions but I never get any errors. Am I missing a step before uploading? Here is the code:
- (IBAction)sendPressed:(UIButton *)sender
{
NMSSHSession *session = [NMSSHSession connectToHost:@"***.com:22" withUsername:@"***"];
if (session.isConnected) {
NSLog(@"Connection suceeded");
[session authenticateByPassword:@"***"];
if (session.isAuthorized) {
NSLog(@"Authentication succeeded");
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Archive-Small" ofType:@"zip"];
[session.channel uploadFile:filePath to:@"/test/" progress:^BOOL(NSUInteger value) {
NSLog(@"Progress: %d", (int)value);
return YES;
}];
}
}
[session disconnect];
}
* UPDATE *
@interface SFTPVC ()
{
NMSSHSession *session;
}
@end
@implementation SFTPVC
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (IBAction)connectPressed:(UIButton *)sender
{
session = [NMSSHSession connectToHost:@"***:22" withUsername:@"***"];
if (session.isConnected) {
NSLog(@"Connection suceeded");
[session authenticateByPassword:@"***"];
if (session.isAuthorized) {
NSLog(@"Authentication succeeded");
}
}
}
- (IBAction)sendPressed:(UIButton *)sender
{
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Archive-Small" ofType:@"zip"];
[session.channel uploadFile:filePath to:@"/test/" progress:^BOOL(NSUInteger value) {
NSLog(@"Progress: %d", (int)value);
return YES;
}];
}
- (IBAction)disconnectPressed:(UIButton *)sender
{
[session disconnect];
}
// Session delegates
- (void)session:(NMSSHSession *)session didDisconnectWithError:(NSError *)error
{
NSLog(@"didDisconnectWithError: %@", [error description]);
}
// Channel delegates
- (void)channel:(NMSSHChannel *)channel didReadError:(NSString *)error
{
NSLog(@"didReadError: %@", [error description]);
}