readBinaryStream() - ok on iOS, broken on Android


#1

Differences between executing readBinaryStream() on iOS and Android


readBinaryStream() executes correctly on iOS but not on Android.  On iOS, the header is correct.  On Android, the header is missing the multi-part/form-data, boundary and content-length.  Code sample is included at the end of this post


Here's an excerpt of a POST statement using readBinaryStream() on IOS


POST /upload_zip.php HTTP/1.1
Host: 10.0.1.8:80
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=7deb806ef7d17a32
Content-Length: 363517

Accept-Language: en-us
Accept: */*
Connection: keep-alive
User-Agent: BirdsEarApp/0.8.0 CFNetwork/672.0.8 Darwin/13.0.2


--7deb806ef7d17a32
Content-Disposition: form-data; name="uploaded_file"; filename="_140102_112246689_ThuJan2_1122AM.zip"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

....

Here's an excerpt of a POST statement using readBinaryStream() on Android


POST /upload_zip.php HTTP/1.1
User-Agent: Dalvik/1.4.0 (Linux; U; Android 2.3.4; ADR6300 Build/GRJ22)
Host: 10.0.1.8
Connection: Keep-Alive
Transfer-Encoding: chunked
Accept-Encoding: gzip


3f9
--c86be7cc36648a53
Content-Disposition: form-data; name="uploaded_file"; filename="app_61_140102_142322882_ThuJan2_0223PM.zip"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

....

Code Sample:

 

    // Upload zipfile to server

    File zipFile(zipFileName);  
    String BEIserverURL("http://10.0.1.8:80/upload_zip.php"); 
    String parameter("uploaded_file");
    String mimeType("application/octet-stream");


    URL url(BEIserverURL);
    url = url.withFileToUpload(parameter, zipFile, mimeType); // File + MimeType

    MemoryBlock blk;
    bool bPOST = true;
    url.readEntireBinaryStream(blk, bPOST);   // POST file to server


    // Check response
    const char *msg = (const char *)blk.getData();
    
    logMsg("readEntireBinaryStream returned: %s", msg);