-
Notifications
You must be signed in to change notification settings - Fork 2
Assignment: Simple storage server
This is an API specification for a simple HTTP-based multi-user file storage server. Your assignment is to write a simple server that implements this API using a language of your choice.
There are five API endpoints to implement:
This endpoint is used to register as a new user. Usernames must be at least 3 characters and no more than 20, and may only contain alphanumeric characters. Passwords must be at least 8 characters.
Content-Type: application/json
{
"username": "the username of the user to create",
"password": "the password of the user to create"
}
Status: 204 No Content
Status: 400 Bad Request
Content-Type: application/json
{
"error": "explanation of failure"
}
This endpoint is used to log in as an existing user. On success, it returns a session token. The session token should be included in future requests to authenticate the sender.
Content-Type: application/json
{
"username": "the username of the user to log in as",
"password": "the password of the user to log in as"
}
Status: 200 OK
Content-Type: application/json
{
"token": "an opaque session token"
}
Status: 403 Forbidden
Content-Type: application/json
{
"error": "explanation of failure"
}
This endpoint is used to upload a file to the logged-in user's personal storage.
Content-Length: <file size>
Content-Type: <content type>
X-Session: <session token>
<file bytes>
Status: 201 Created
Location: /files/<filename>
This endpoint is used to get a file from the logged-in user's personal storage.
X-Session: <session token>
Status: 200 OK
Content-Length: <file size>
Content-Type: <content type>
<file bytes>
Status: 403 Forbidden
Status: 404 Not Found
This endpoint is used to delete a file from the user's personal storage.
X-Session: <session token>
Status: 204 No Content
Status: 403 Forbidden
Status: 404 Not Found
This endpoint is used to list files in this user's personal storage.
X-Session: <session token>
Content-Type: application/json
[
<filenames...>
]
Status: 403 Forbidden
If you choose, you can use the project skeleton to either implement your server or as a base for your code in whatever language you choose. You can use the DataStorage class (or equivalent in whatever language you choose) as is (unless there are bugs in that code, then you must fix those), as an in-memory data store.
To submit the assignment, put the code in a repository under your GitHub account and send a link to the repository to your recruiter contact at New Alchemy.
Please include a README that documents how to compile/run your code. If your code relies on 3rd party libraries include in the README instructions on how to install them, e.g. if using python with pip you should include a requirements.txt and documentation in the README saying to pip install -r requirements.txt