php - Temporary storage on a server -
i'm looking efficient , secure way store small amount of user data line of text, indefinite period of time. scenario: 1 client 'a' sends data client 'b' , asynchronously via server 's'. simplicity, consider data single line of text. now, data delivered client 'b' server 's' , only when b asks it. until time server 's' has store data.
for simple demo, implemented crudely follows:
client 'a' post request xmlhttprequest, sending text 's' follows
xhr.open("post",url+"?senttext=text"); //url points php file on s xhr.send();
the php code saves received text file follows:
<?php $selected = $_get["senttext"]; $writefile = "text.txt"; $fh = fopen($writefile,'w'); fwrite($fh,$selected); fclose($fh); ?>
later, after amount of time, b asks text in file,using bufferedinputstream follows:
url fileurl = new url("url/text.txt"); bufferedreader in = new bufferedreader(new inputstreamreader(fileurl.openstream())); while((tmpreceived = in.readline())!=null){ received = tmpreceived; }
this demo works properly, demo. however, if full scale real world application millions of users, how implement following:
the part server s stores text. obviously, can't save text plain text in file, breach users' privacy. , ineffecient when there millions of users. how commercial services dropbox achieve this?
to keep things simple, need know how text, can extrapolate other types possibly.
thanks lot!
Comments
Post a Comment