Skip to content

General API to handle receiving of large data file chunks via HTTP requests

Notifications You must be signed in to change notification settings

ehsu4220/Dockerized-Flask-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dockerized-Flask-API

General API to handle uploads of large data files via HTTP requests

  • Elements within <> are values you must fill in

Requirements

  • Host machine with Docker CLI
  • Docker Desktop for remote repository of docker image

app.py

General endpoints to handle processing uploads of entire files or chunks.

  • Entire file uploads are saved to the uploads folder and reflected onto the mounted directory on host machine
  • Chunk uploads require addition information to restructure the file from received chunks (i.e., chunk number, total number of chunks)
  • Entire files are handled through Forms, Chunks are handled through Header values
  • Chunks are stored until all are received in order to reformulate the file
    • Files are reformulated via the async method, process_data() through threads.

This version is implemented with use of TLS 1.2 encryption via host machine .pem and .key files for verification

Building Dockerized Application onto Remote Server

Move to the directory with the Dockerfile

Run docker build -t <image-name> .

Tag the docker image

  • docker tag <image-id> <repository-name>:<tag>
  • repository-name is in the form <username>/<image-name>

Push docker image to an online repository

  • docker login
  • docker push <repository-name>:<tag>

Log into remote server, run the following command to pull from the online repository

  • docker login
  • docker pull <repository-name>:<tag>

Running Docker image in a container in detached mode w/ mounted local directory

To have the Flask application's /app/uploads directory mounted to a given file directory on host machine

  • docker run -d -v <host-machine-directory>:/app/uploads -p <host-port-number>:<container-port-number> <Docker-image>

Miscellaneous configuration for Docker container that you can do

Setting name to container during the mounting process

  • docker run -d --name <container-name> -v <host-machine-directory>:/app/uploads -p <host-port-number>:<container-port-number> <Docker-image>

Checking the uploads folder of the dockerized flask server:

  • docker exec -it <Docker-container-ID> ls ./uploads

Additional Features that need implementation

  • Inclusion of a method to request files from the host machine via GET request.
  • Deletion of specific files via DELETE requests.
  • System for generating and checking API keys before allowing service.

About

General API to handle receiving of large data file chunks via HTTP requests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published