Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4632] Can't open a large file as a stream

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionCannot Reproduce
Resolution Date2011-10-31T13:09:42.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sSprint 2011-44
ComponentsAndroid
Labelsfilesystem, streams
ReporterMark Burggraf
AssigneeHieu Pham
Created2011-07-06T10:00:11.000+0000
Updated2017-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

FileDateSize
bigText.txt.zip2011-10-31T13:12:28.000+0000347477

Comments

  1. Paul Dowsett 2011-07-09

    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 you
  2. Mark Burggraf 2011-07-09

    I 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.
  3. Mark Burggraf 2011-07-09

    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.
  4. Paul Dowsett 2011-07-09

  5. Dawson Toth 2011-07-12

    There's also the undocumented "Ti.Filesystem.openStream(Ti.Filesystem.MODE_READ, 'test.log')" method to contend with.
  6. Don Thorp 2011-07-12

    Mark, Paul, Dawson. Is this still occurring after TIMOB-4612?
  7. Hieu Pham 2011-10-31

    Test Code: "bigTexts.txt" is uploaded to this ticket. It is 46mb.
       var win = Ti.UI.createWindow();
       var infile = Ti.Filesystem.getFile("bigTexts.txt");
       var instream = infile.open(Titanium.Stream.MODE_READ);
       win.open();
       
    Git hash version: commit e69cc8f31db0e3745f6bbdef2934be0cc9e1407e Merge: 9aea8e9 e4a5362
  8. Lee Morris 2017-03-31

    Closing ticket as it has been over 5 years since the last update. Please open a new ticket if you have a problem.

JSON Source