Can anyone please help with the correct way to encode an image so that I can send it via web services to my content management system?
The following should work but the encoded file doesn't decode back into the original so it can't be viewed as an image any longer.
var f = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory,'KS_nav_phone.png'); var blob = f.read(); var encoded = Ti.Utils.base64encode(blob.toString());
Is this a bug in converting blobs to strings then encoding to base64 or am I'm missing something totally obvious here?
Thanks in advance!
This isn't an answer but it is an explanation. blob.toString() returns this text [object TiBlob] which base64 encodes to a non-image. If I find an answer, I'll let you know.
When sending images, I just let the http client encode it the image for me - just like the kitchen sink example. They only thing I had to change from the example was setting the content-type: