[TIMOB-12079] Android: Data retrived from a socket is corrupt when writing to file
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2013-04-25T15:50:30.000+0000 |
Affected Version/s | Release 2.1.3, Release 2.1.4, Release 3.0.0, Release 3.1.0 |
Fix Version/s | n/a |
Components | Android |
Labels | exalture |
Reporter | Daniel Sefton |
Assignee | Sunila |
Created | 2012-12-12T22:36:15.000+0000 |
Updated | 2017-03-24T17:53:13.000+0000 |
Description
*Problem description*
When writing an image obtained from a TCP socket to file, the file is becoming corrupt and the image isn't displayed. The binary data that we are receiving from the socket is proper in size but after writing to the file the size is greater than the actual image.
*Log*
12-12 14:28:02.150: I/TiAPI(29051): Successfully total read. 83122
12-12 14:28:02.150: I/TiFileProxy(29051): (KrollRuntimeThread) [2,1061] Unable to write to an unrecognized file type
*Test case*
Attached.
Attachments
File | Date | Size |
---|---|---|
zTCP.zip | 2012-12-12T22:36:15.000+0000 | 755070 |
Tested and confirmed on Samsung Galaxy S2 2.3.6 and Android Emulator Ti SDK 3.0.0, 2.1.3 GA, and 2.1.4 GA.
Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) Device: Samsung galaxy s duos Android version: 4.0.4 jithinpv
Couple of issues with the sample. 1. The error "Unable to write to an unrecognized file type" is because the tmpFile.write(e.buffer, true) where e.buffer is of Titanium.Buffer and File.Write doesn't support this Buffer type 2. The file size is too large because the file is not binary. Use FileStream(Ti.Filesystem.openStream) instead of File to write the binary data
Closing ticket as invalid with reference to the above comments.