Hi folks, for manual uploading of an image I have to embed the raw image data between the boundaries and headers (Mime). Because the camera deploys TiBlob and I have to convert the TiBlob to Buffer.
header = ''; header += '--' + BOUNDARY + CRLF + 'Content-Disposition: form-data; name="mytext"' + CRLF + 'Content-Type: text/plain' + CRLF + CRLF + xmlString + CRLF; header += '--' + BOUNDARY + CRLF + 'Content-Disposition: form-data; name="myfile"; filename="' + filename + '"' + CRLF +'Content-Type: image/jpeg' + CRLF + CRLF; var full_content = Ti.createBuffer({ value : header }); streamMedia = Ti.Stream.createStream({ source : imageBlob , mode : Ti.Stream.MODE_READ }); // here the important code line:::: full_content.append(Ti.Stream.readAll(streamMedia)); // ::::: full_content.append(Ti.createBuffer({ value : CRLF + '--' + BOUNDARY + '--' + CRLF }));For debugging pupuse I send the builded body to my local machine. On iPhone all is good, but on Android the image is modified and a part of image readers cannot display. I have opened multipart stuff and stripped from boundaries and headers.
ls -alshow a difference:
-rw-r--r-- 1 rainerschleevoigt staff 858586 Jul 4 14:47 JPG.bin -rw-r--r--@ 1 rainerschleevoigt staff 861242 Jul 4 14:49 MULTIPART.binThe head and tail is same, but the converted image is a little bigger. Here the hexdums: original JPG, stripped Post
Your Answer
Think you can help? Login to answer this question!