A simple Tornado backend that provides an API endpoint receiving pdf files and storing files metadata (filename and upload date) into a Postgres database.
Clone the repository
git clone https://github.com/SoFish1/load_file_api.git
cd load_file_apiTo set up the environment, copy .env_file in the current folder. Then run the following command
docker-compose --env-file .env_file upThe backend validates the input data by checking the following requirements:
- The request header content-type shall be
bash multipart/form-data - The request body shall be of the following type
bash {'file': file_content}where only one file per request is allowed - The filename shall be shorter than 20 chars
- The file shall be a PDF
- A sanity check is performed on the file thanks to the Cloudmersive API provider
A testing module is also provided to test the endpoint. To perform the tests run the following command in the project folder:
python -m unittest .\tests\test.py A PGAdmin service is also provided to visualize the database and to check that everyting is as expected.
The code is linted with Pylint VSCode extension