Ascii-less-gallery is a sample project combining AWS Lambda functions,
Serverless framework and Kotlin language. It was inspired by
serverless-photo-recognition github project. Intention was to try to
setup project that use AWS Lambda functions with minimal effort - everything thanks to
Serverless framework
- custom authorization leveraging redis for caching user access tokens - this reduce numbers of request (cost) to AWS DynamoDB
- user login and registration
- image upload and conversion to ascii
- storing labeled images in ElasticSearch - labeling is done using AWS Rekognition service
- Create ElasticSearch domain
es-gallery - Create Redis - due to not being able to call Redis from Lambda I decided to use redislabs free plan.
- One manual tweek is required to make it all work. Login to AWS Management Console and navigate to API Gateway service then on the left side select
dev-ascii-less-gallery-servicenextBinary supportand add files you want to be supporting likeimage/png
- Install and configure serverless framework (Instruction)
- Build project ./gradlew build
- Run
sls deploy(I'm using dedicated account for serverless calledslessand it is set in serverless.yml file). When deploy finish successfully all functions URLs will be printed in the console window.
- Register new user:
curl -X POST \
https://xxxx/dev/register \
-H 'content-type: application/json' \
-d '{"email":"test@test.com", "password":"admin"}'- Obtain user access token:
curl -X POST \
https://xxxx/dev/login \
-H 'authorization: Basic dGVzdEB0ZXN0LnBsOmFkbWlu'- Upload image for recognition and conversion to ascii
curl -X POST \
https://xxxx/dev/gallery \
-H 'content-type: image/png' \
-H 'token: eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE0OTQ5NTA0NDgsImlzcyI6InRlc3RAdGVzdC5wbCJ9.Dj0itEWPE2PQ6WbeLgIWgHwslaVLWAgRlj-2scJ8Uk4'- List all images
curl -X GET \
https://xxxx/dev/gallery - User can delete his documents:
curl -X DELETE \
https://xxxx/dev/gallery/def2c0d8-5d13-4603-83ef-79bf9e07944d \
-H 'token: eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE0OTQ5NTA0NDgsImlzcyI6InRlc3RAdGVzdC5wbCJ9.Dj0itEWPE2PQ6WbeLgIWgHwslaVLWAgRlj-2scJ8Uk4'