Christian V
Christian V

Reputation: 105

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

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

Upvotes: -2

Views: 662

Answers (2)

dda
dda

Reputation: 6213

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.

Upvotes: 0

Ben
Ben

Reputation: 35653

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

Upvotes: 0

Related Questions