An example service which listens for images in firebase and converts them to ascii
- Docker / Docker Compose installed and configured. (See documentation here)
- Firebase Account - To use Storage you need to generate an Admin SDK file, Project Settings -> Service Accounts -> Generate New Private Key
.env
file with the following content
API_KEY=""
AUTH_DOMAIN=""
DATABASE_URL=""
PROJECT_ID=""
STORAGE_BUCKET=""
MESSAGING_SENDER_ID=""
This service listens for any files that are added to a Firebase Storage bucket. When a file is added, the service pulls the file down and generates an ASCII representation of that file and uploads it back to the Firebase Storage bucket with the prefix ascii-
Since the Storage resource of Firebase does not have a stream api available, we use a simple polling technique to check for new files.
$ docker-compose build .
$ docker-compose up
Or use the helper script
$ ./run.sh
- Currently the way we determine whether we have processed a file is by seeing if we have that file in the
/images/*
subdirectory. This is not scalable. Think of a better way to keep track of which files have been converted so that we do not have to convert all the files on every update. - Converting from image to ascii to image requires a downsample where we lose the aspect ratio. Think of a way to maintain the aspect ratio of the original image.
- We are currently polling for new data, this can result in unecessary API calls. Think of a way to make use of the
streaming
API as a proxy to notifying of new files. Or think of a different way to be updated that a new file is available - Perform a type check to make sure you are actually processing a valid image file
- Use
jpg
to reduce the footprint of the processed image