bytearray uncompress filestream wirtebytes error
Hi,
I'm developing an app for iPad in which I'm trying to load a zip file from a remote url, save that zip file on device and then trying to unzip it.
It works fine both on laptop(while testing as AIR app) and also on the device(iPad) if zip file size is around 20 - 25MB, with it's internal file being around 140 - 170MB. But if the zip file size is larger (beyond 50MB) then it crashes while uncompressing the zip file on the device. It still works fine on laptop though.
I'm compiling the code with Flex 4.6 overlayed on AIR 3.6
iPad iOS version is 6.0.1
Using following code :
private function unzipFile():void
{
progress = progress + fileName +' unzipFile started\n';
saveLog();
var zStream:FileStream = new FileStream();
var bytes:ByteArray = new ByteArray();
var fileName:String = new String();
var flNameLength:uint;
var xfldLength:uint;
var offset:uint;
var compSize:uint;
var uncompSize:uint;
var compMethod:int;
var signature:int;
progress = progress + fileName +'before zStream.open\n';
saveLog();
zStream.open(fileLocal, FileMode.READ);
progress = progress + fileName +'after zStream.open\n';
saveLog();
bytes.endian = Endian.LITTLE_ENDIAN;
while (zStream.position < fileLocal.size)
{ progress = progress + fileName +'before zStream.readBytesbytes, 0, 30\n';
saveLog();
zStream.readBytes(bytes, 0, 30);
progress = progress + fileName +'after zStream.readBytesbytes, 0, 30\n';
saveLog();
bytes.position = 0;
signature = bytes.readInt();
if (signature != 0x04034b50)
{
break;
}
bytes.position = 8;
compMethod = bytes.readByte();
offset = 0;
bytes.position = 26;
flNameLength = bytes.readShort();
offset += flNameLength;
bytes.position = 28;
xfldLength = bytes.readShort();
offset += xfldLength;
zStream.readBytes(bytes, 30, offset);
bytes.position = 30;
fileName = bytes.readUTFBytes(flNameLength);
bytes.position = 18;
compSize = bytes.readUnsignedInt();
bytes.position = 22;
uncompSize = bytes.readUnsignedInt();
progress = progress + fileName +'before zStream.readBytes(bytes, 0, compSize)\n';
saveLog();
zStream.readBytes(bytes, 0, compSize);
progress = progress + fileName +'after zStream.readBytes(bytes, 0, compSize)\n';
saveLog();
if (compMethod == 😎
{
try
{
progress = progress + fileName +' before bytes.uncompress\n';
saveLog();
bytes.uncompress(CompressionAlgorithm.DEFLATE);
//bytes.uncompress(CompressionAlgorithm.LZMA);
progress = progress + fileName +' after bytes.uncompress\n';
saveLog();
//outFile(fileName, bytes);
}
catch(error:Error)
{
progress = progress + fileName +' bytes.uncompress catch\n';
saveLog();
}
}
//write bytes to a file locally here
}
}
It fails on this line:
bytes.uncompress(CompressionAlgorithm.DEFLATE);
and gets inside catch block.
To avoid this problem, I also tried to load the file which was there in the zip file, directly using remote url(file size and download time will be more), but in this case, after loading the file, reading the bytearray data of it, when I try to write this bytearray to a filestream, it crashes again! ![]()
Just wanted to know if there is any file size limit on mobile\iOS devices, while unzipping a file and while writing bytearray data to a filesystem or am I doing something wrong here?
Kindly help, as I'm stuck with this and cannot really proceed on this project using Flex AIR if this doesn't work.
-Deepak
