Cyberstick is a temporary cloud server. What this means is that you can store files here for 15 minutes to have someone download them and then forget about them. This can be used among friends; if you want to share a song you just made in garageband, pop it into Cyberstick and give them the three word key. What if you wanted to move a photo onto your computer from your phone and don’t have a cable handy? This website works perfectly on mobile devices and should not cause any problems.
Cyberstick is built in Python using the open-source libraries shutil, pdb, stripe, jinja2, python-flask, werkzeug, urllib2 and TinyDB.
When a user opens the upload page, the server builds a session ID by picking 3 random numbers with the built-in Python function randint, which are used to select 3 words from a list. The server then creates a session folder locally with the naming system [UNIX time]-[Session ID].
The server displays a webpage created by injecting content into a custom-built jinja2 template. This template contains a drag ‘n’ drop box for uploading files and the session ID which is passed through jinja2 as a string. Any files that are uploaded are saved to the session folder.
Another python script has a loop which lists all sessions folders and compares the marked UNIX time to the current UNIX time and if the folder is over 900 seconds, wipes the content of the folder and then deletes the folder.
The download link is created using the session ID so it is easier to remember and communicate.
The API simply sends a request to the server using curl http request. It requests an upload folder. The server builds it and responds in JSON giving the error code (if any) and the session ID. Using the received session ID, the API then makes a POST request to the server uploading the files. To download files, the API sends a download request with the session ID, the server responds with file names and the API downloads them directly.
When a user wants to create a user ID, they are redirected to a payment system that sends back a confirmation key such as stripe. When the server receives this confirmation key, it forgets it, generates an ID with 6 random words and checks that this ID has not been already used, and if it has not, saves it to the database together with the number of sessions that the user has bought. The last thing it does is it displays the user ID and saves it to an encrypted cookie. The name and payment information are not saved. To login, you must write the user ID. Sessions that are created by a user that is logged in, the folder name includes the user ID. This allows the user to see their own sessions for the system scans the folders and displays the ones whose name contains the user’s ID. The user can also add more sessions to their user ID by adding their key on the checkout page which causes the server to repeat everything in a normal purchase but without randomizing the key and using the given key instead.
© CoderDojo Dublin @ The Warehouse 2015.
All rights reserved.