readAsDataURL limited the file size?

  • 2
  • Problem
  • Updated 9 years ago
Hello,
using phonegap 0.9.6
device: Blackberry curve 8520
OS 5.

My target is to allow the user to select img or video and send it to the server.
So I pass the file's path to readAsDataURL(path) to read it and send the result to the server.

I success in doing that with PhoneGap FileReader API but the problem arise is that when I try to upload img larger than 3.1 Mega the File has not been read in memory.

so I decide to not read the whole file in memory, instead I'll get a slice of the file then read it and upload it to server then get the next slice of file and upload it and so on till the end of file.

I success in donig that in a web page running in chrome browser in my desktop but I couldn't do that in Blackberry.

This is my code.

input type="file" id="files" name="files"/

var files = document.getElementById('files').files;

// in this point the file variable is undefined so it fail to do the rest of code ??!!

var file = files[0];

//loop till the End of File
{
var blob = file.slice(beginIndex, endIndex);

fileReader.readAsDataURL(blob);

// send the result to server

}

Could any one explaibn to me why readAsDataURL can't read files larger than 3.1 miga, is that related to device memory?

and how could I make slice method which in File API works?
Photo of dina.salah86

dina.salah86

  • 34 Posts
  • 0 Reply Likes
  • too sad

Posted 9 years ago

  • 2
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Hey Dina,

I can only take a guess at this one, however what I'm assuming is that the application has a limit on the memory it is allowed to consume. On a side note you may want to also make sure that the following code is even possible on the device. Try to see if all of those function calls are actually possible. (Both of the mentioned comments vary from device to device).

However if anyone can provide more information who has used this device should do so.

Hardeep Shoker