Which is the best way to store a pdf around ~4mb in sqlite with javascript?

662 Views Asked by At

Which is the best way to store a pdf around ~4mb in sqlite with javascript?

I have tried using base 64 encoding but the Andoid browser freezes and quits when trying to open large files. Small files won't open either they just start to download but the download never completes and the filetype seems to be unknown. It has to work in the Android browser, and I have several files that I need to save so I have to use sqlite (because of size limits in offline storage)

Thanks in advance! /Christian

2

There are 2 best solutions below

1
On

You might want to consider PhoneGap for creating a Native application, thereby bypassing quotas. That way you can continue to use HTML5 to create the app.

This blog entry suggests a way to lift quota limits for PhoneGap apps:

http://blog.mattray.info/2011/08/into-blender-javascript-sqlite-ios-and.html

1
On

You could read the PDF in chunks (asking the server to send over bytes xx to yy), to minimize the impact on the mobile system, and store that in an sqlite table with a tracking number (chunk x of y) until you have everything. Then you could rebuild at any time the whole file as a big blob, and save that blob to a temp file -- see the link above for filesystem from html5rocks.