0

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);

NSString *stringSentToServer = [data base64EncodedString];

// POST data to nodeJS
var fs = require('fs');
fs.writeFile("mydirectory/image.png", "data:image/png;base64,"+(POSTED stringSentToServer 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?

** EDIT ** I've tried AFNetworking multipart upload. I'm receiving positive progress callback, but the image is still corrupt on the server.

GameDevGuru
  • 1,095
  • 2
  • 12
  • 27

0 Answers0