I'm trying to send a image from mydevice to server use Socket.
I used this code to convert from image to bytes. After that, I sent bytes to server:
- (IBAction)btnSend:(id)sender {
UIImage *image = [UIImage imageNamed:@"button.png"];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
// NSLog(@"data: %@", imageData);
NSString *string = [NSString stringWithFormat:@"%@", imageData];
NSDictionary *deviceDic = @{@"RequestType": @"5",
@"StringData":string};
NSData* bodyData = [NSJSONSerialization dataWithJSONObject:deviceDic
options:kNilOptions error:nil];
[socket writeData:bodyData withTimeout:-1 tag:0];
}
But, my bytes array is very big so, I want to send ever bytes to server.