problem
Using
Ti.Stream.read()
with an open
Ti.Filesystem.FileStream
does nothing. The read call never invokes the result callback. Android works fine, but iOS always fails as described above, despite the documentation indicating that both support
Ti.Stream.read()
on FileStream. Without this support there is no asynchronous way to read files with Titanium on iOS, all reads must be blocking.
test case
var file = Ti.Filesystem.getFile('app.js')
var stream = file.open(Ti.Filesystem.MODE_READ);
var buffer = Ti.createBuffer({length:8096});
Ti.Stream.read(stream, buffer, function(e) {
Ti.API.error('I never get here');
Ti.API.error(e);
});
expected
The results callback should return an event object (
e
) containing all relevant information regarding the read operation. Both
Ti.API.error
calls should execute and print the results.
actual
The results callback is never executed. Nothing is printed.
Pull pending master - https://github.com/appcelerator/titanium_mobile/pull/6381 3_5_X - https://github.com/appcelerator/titanium_mobile/pull/6382
[~tlukasavage] I tried to verify this ticket with the above mentioned testcase. It's crashing while opening the file object. Can you please have a look?
Closing ticket as fixed. Verified Ti.Stream.read() is working i.e. the event object is returned back in the callback. Used the following modified code:
Instead of Ti.Filesystem.getFile('app.js'), created another text file and used Ti.Filesystem.getFile('timob18078.txt'); I think you will not be able to access app.js via Ti.Filesystem.getFile because of security reasons. Tested on: Appcelerator Studio, build: 3.4.1.201410281743 SDK build: 3.5.0.v20141125154115 CLI: 3.4.1 Alloy: 1.5.1 Xcode: 6.1.1 GM Seed Devices: iphone 6 plus (8.1), Samsung Galaxy S4 (4.4.2)
[~wluu] Thanks for clarifying it.
Yeah, I believe app.js will only work on simulator tests. Thanks for the fix.