[TIMOB-4632] Can't open a large file as a stream
GitHub Issue | n/a |
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2011-10-31T13:09:42.000+0000 |
Affected Version/s | Release 1.7.0 |
Fix Version/s | Sprint 2011-44 |
Components | Android |
Labels | filesystem, streams |
Reporter | Mark Burggraf |
Assignee | Hieu Pham |
Created | 2011-07-06T10:00:11.000+0000 |
Updated | 2017-03-31T17:23:45.000+0000 |
Description
When trying to open a large file in order to copy it to another location, the app crashes, trying to allocate enough memory to copy the entire file into memory. This happens on the call to open the file, so a buffered read of a large file is not possible. For example:
var infile = Ti.Filesystem.getFile("app://myLargeFile.db");
var instream = infile.open(Titanium.Stream.MODE_READ);
In this case, myLargeFile.db is a 13mb file, and causes the app to crash on the call to infile.open.
Attachments
I am not aware of any
Ti.Filesystem.File.open()
method. Please would you change your usecase code to use only the methods published in the [official APIDocs](http://developer.appcelerator.com/apidoc/mobile/latest). Thank youI am using code posted on your official blog, here: Titanium Mobile Intro Series: Streams Published on May 4, 2011 by Bill Dawson (Platform Engineer) http://developer.appcelerator.com/blog/2011/05/titanium-mobile-intro-series-streams.html I am using the exact sample code posted in this article under the FileStream Example.
Speaking of documentation... The FileStream object is documented here: http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Filesystem.FileStream-object.html However, there are no open methods documented -- only close methods. The examples are incomplete and confusing, saying things like: var inStream = // stream object could be socket, file, buffer or blob This is an incomplete example. How do you open a file object as a stream? The documentation says it's possible, but does not say how.
There's also the undocumented "Ti.Filesystem.openStream(Ti.Filesystem.MODE_READ, 'test.log')" method to contend with.
Mark, Paul, Dawson. Is this still occurring after TIMOB-4612?
Test Code: "bigTexts.txt" is uploaded to this ticket. It is 46mb.
Git hash version: commit e69cc8f31db0e3745f6bbdef2934be0cc9e1407e Merge: 9aea8e9 e4a5362
Closing ticket as it has been over 5 years since the last update. Please open a new ticket if you have a problem.