This project is an API to save file on Google Store for the technical test of MOVTI
- Requirements
- Environment Variables
- Build your Storage on Google
- Setup
- Running
- Running with Shell
- Code Documentation
- Code Analysis
- Execute Unit Test
- Accessing API URLs
To run this project, you need to install the Docker and Docker Compose.
The Environment Variables of this container are:
- API_MODE: The mode of API. The mode can be 'prod' or 'devel' (Default: prod)
- STORAGE_ROOT_PATH: The path to save the files at storage (Default: /)
- GCLOUD_PROJECT: The name of Google Cloud Project (Default: filesave)
- GCLOUD_STORAGE_BUCKET: The name of Google Cloud Storage (Default: filesave-storage)
- GCLOUD_STORAGE_CHUNK_SIZE: The chunk size must be a multiple of 256KB (Default: 524288)
First of all, you need to create your project at Google Cloud (see the documentation). Now, you can create your storage (see the documentation). After that, you need to get the credential file of Storage and save as service-account.json
. See the documentation of Authentication for more details (Link of documentation)
To set up the container, you need to execute:
docker-compose build
This command will build the container follow the steps in Dockerfile
.
After setup the container, you can run the services with the following command:
docker-compose up
To run with shell, you need to execute
docker-compose run --service-ports api sh
After that, you run with the following command:
make run
If you want to see the documentation of code, you need to execute the following command after run the container with shell:
make docs
Now, you can access the code documentation opening the file docs/build/index.html
If you want to analyze your python code that was written inside the src
folder, you need to execute the following command after run the container with shell:
make lint
If you want to execute the unittest, you need to execute the following command after run the container with shell:
make tests
To access the URLs of API, you can use the command line curl or the Postman
To upload a file to the Storage, you need to execute:
touch test.txt
curl -X POST -F 'file=@./test.txt' http://127.0.0.1:5000/file
To get the list of file, you need to execute the following command:
curl -X GET http://127.0.0.1:5000/file
To get the the specific file, you need to execute the following command:
curl -X GET http://127.0.0.1:5000/file/test.txt
To delete the file you need to execute:
curl -X DELETE http://127.0.0.1:5000/file/test.txt