Advertisement
Guest User

Untitled

a guest
Apr 6th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. NMSSHSession *session = [NMSSHSession connectToHost:@"host"
  2. withUsername:@"user"];
  3. if (session.isConnected) {
  4. if (!session.isAuthorized) {
  5. NSArray *authTypes = [session supportedAuthenticationMethods];
  6. }
  7.  
  8. NSString *privateKey = [[NSBundle mainBundle] pathForResource:@"privatekey" ofType:nil];
  9. [session authenticateByPublicKey:nil
  10. privateKey:privateKey
  11. andPassword:nil];
  12.  
  13. if (session.isAuthorized) {
  14. NSLog(@"Authentication succeeded");
  15. }
  16. }
  17.  
  18. NMSFTP *sftp = [[NMSFTP alloc] initWithSession:session];
  19. [sftp connect];
  20.  
  21. UIImage *image1 = [UIImage imageNamed:@"flower.jpg"];
  22. UIImage *image2 = [UIImage imageNamed:@"Wall.jpg"];
  23. UIImage *image3 = [UIImage imageNamed:@"Circle.jpg"];
  24. NSMutableData *data = [[NSMutableData alloc]init];
  25. NSMutableData *data2 = [[NSMutableData alloc]init];
  26. NSMutableData *data3 = [[NSMutableData alloc]init];
  27.  
  28. [data appendData:UIImagePNGRepresentation(image1)];
  29. [data2 appendData:UIImagePNGRepresentation(image2)];
  30. [data3 appendData:UIImagePNGRepresentation(image3)];
  31.  
  32. [sftp writeContents:data toFileAtPath:@"serverPath/filename.jpg"];
  33. [session disconnect];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement