-
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 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
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.