A file storage that allows you to share a file via a link with other people, customize file permissions, and display a list of the most downloaded files.
Fork project's repository.
Load it to your machine.
You must have python3 installed and create virtual environment.
To install all required packages open command prompt, activate virtual environment, go to project's directory and write
pip instal requirements.txt. When all packages would be installed use commands python manage.py collectstatic
to collect project's static files and python manage.py runserver to run djnago server on 8000 port of your machine (for example localhost:8000)
All urls starts with domain name of your machine and port number on which you run the application.
For example http://localhost:8000 or http://blablabla.bla:1234.
request:
- url: /api/user/
- method: POST
- data:
{
'email': string,
'username': string,
'first_name': string,
'last_name': string,
'password': string
}
response:
{
"email": string,
"username": string,
"first_name": string,
"last_name": string,
"id": integer
}
request:
- url /api/auth/token/login/
- method: POST
- data:
{
"email": string,
"password": string
}
response:
{
"auth_token": string
}
To be authenticated you need to pass token to headers in your following requests, like here:
'Authorization': 'Token <your token>'
request:
- requires authorization
- url /api/auth/token/login/
- method: GET
request:
- requires authorization
- url /api/files/
- method: POST
- data (in form-data format):
'file': file,
'access': string
response:
{
"access": string,
"file": string
}
Unauthorized users can read only public files. Authorized users can read only public and their own files.
- url /api/files/
- method: GET
- query parameters:
limit: int - maximum items on one page
page: int - page number
response: without query parameters:
[
{
"id": int, - file's id in database
"access": string, - file's access type
"file": string, - file name in database
"download_count": int, - number of downloads
"author": int - file authod's id
}
]
with query parameters:
{
"count": int, - number of elements on one page
"next": string, - next page address
"previous": string, - previous page address
"results": [
{
"id": int,
"access": string,
"file": string,
"download_count": int,
"author": int
}
]
}
If file is public all users can view and download it.
If file is only_author only author of file can view and download it.
if file is by_link users can open it if they have link.
request:
- requires authorization
- url /api/files/<file_id_in_database>/
- method: PATCH
- data:
{
'access': string
}
response:
{
'id': int,
'access': string
}
You can delete only your files. request:
- requires authorization
- url: /api/files/<file_id_in_database>/
- method: DELETE
Get link on one of your file which you can share to other users. request:
- requires authorization
- url: /api/files/<file_id_in_database>/link
- method: GET response:
{
"id": 16,
"view_link": string, - link to view fiel
"download_link": string - link to download file
}
To view your files you need to be authorized, unlike public files. request:
- url: /api/files/view/<file_name_in_database>/
- method: GET
To download your files you need to be authorized, unlike public files.
- url: /api/files/download/<file_name_in_database>/
- method: GET