javascript - How to keep downloaded file in memory through ajax -
i making html5 web app based on existing ios app. targets recent 2 versions of ios safari browser. web app work, need use api handles communication between current ios app , php backend.
the first hurdle api config files (gzipped) needs downloaded server on regular basis (for example each time app starts) keep updated. need unzip config files, contains key-value pairs of command name , http address. when need command, e.g. display user's profile pic, lookup config files command number find corresponding request address make request server.
to summerize steps:
download (gziped) configuration files ajax
don't think html anchor tag (with or without download attribute) option. because in way safari prompt user open downloaded file using file handling apps (e.g. filesapp). the download must happen in dark.unzip downloaded file
know few js library promise work. haven't tested them yet step 1 not solved. recommandatio welcomed.lookup http address in files whenever making api call
should no problem though.
for ios app, can download config files app sandbox , whatever want it. web app, newest ios safari don't suppor html5 file system api. can do?
step 1.
safari should support http compression. best best leverage this, opposed figuring out way unzip file using javascript. looks there few options php:
or @ server level:
step 2.
use sessionstorage cache configuration settings. data cleared out each time user closes browser.
step 3.
the php handler called ajax request should take care of parsing config files , send javascript-friendly json browser. use json.parse() , json.stringify() serialize/de-serialize data read/save sessionstorage.
Comments
Post a Comment