Thursday, 5 September 2013

Best practice for writing UIImage data to server

Best practice for writing UIImage data to server

I was thinking along the lines of sending base64 encoded NSData of the
UIImage but the image is corrupted. I'm using
https://github.com/nicklockwood/Base64 for Base64 encoding.
NSData *data = UIImageJPEGRepresentation(myViewImage,1.0);
// POST data to nodeJS
var fs = require('fs');
fs.writeFile("mydirectory/image.png", "data:image/png;base64,"+(POSTED
NSData here), function(err) {
if(err) console.log(err); else console.log('Success');
});
The filesize saved looks appropriate, but the image is corrupt. What am i
doing wrong? Or is there a better way to do this?

No comments:

Post a Comment