0

I need to upload an user signature on ipad to server by SOAP web service. The signature will be a MIME attachment for the web service.

Need help to see how can the UIView or jpg on iOS can be converted to binary data MIME format so I can put it as part of the web service. Also, how the NSURLConnection can handle the binary data attachment. Thanks a lot.

atxe
  • 5,029
  • 2
  • 36
  • 50
Mike D
  • 3
  • 2

2 Answers2

0

Check out the GLPaint sample code from Apple, which will give you a view for drawing the signature. It works well in my testing (although you'll want to change the brush texture image): http://developer.apple.com/library/ios/#samplecode/GLPaint/Introduction/Intro.html

Then, as Anomie said, you can use CGBitmapContextGetData() to access the drawn image, and UIImage can convert that into a JPEG for you.

Use NSURLRequest or a third party SOAP library to send the JPEG to the server.

Abhi Beckert
  • 32,787
  • 12
  • 83
  • 110
0

If you need JPEG or PNG format data, you can use UIImageJPEGRepresentation or UIImagePNGRepresentation to convert a UIImage to an NSData object. If you need another format, you may be able to use CGImageDestination; a list of accepted UTIs can be obtained from CGImageDestinationCopyTypeIdentifiers. If you just need raw pixel data, draw the image to a CGBitmapImageContext and then read out the buffer using CGBitmapContextGetData; How to get pixel data from a UIImage (Cocoa Touch) or CGImage (Core Graphics)? may help you there.

As far as NSURLConnection, posts are done using an NSData anyway. It's up to you to format the multipart/form-data structure or SOAP XML document correctly into an NSData, but then NSURLConnection will handle it fine.

Community
  • 1
  • 1
Anomie
  • 92,546
  • 13
  • 126
  • 145