SparrowDB is an image database that works like an append-only object store. Sparrow has tools that allow image processing and HTTP server to access images.
Sparrow consists of three files – the actual Sparrow store file containing the images data, plus an index file and a bloom filter file.
There is a corresponding data definition record followed by the image bytes for each image in the storage file. The index file provides the offset of the data definition in the storage file.
- Built-in HTTP API so you don't have to write any server side code to get up and running.
- Optimizations for image storing.
- Websocket server to provide real time information about the server.
This short guide will walk you through getting a basic server up and running, and demonstrate some simple reads and writes.
Creating a database:
curl -X POST -d '{"type":"create_database", "params":{"name":"database_name"}}' http://127.0.0.1:8081/query
Show databases:
curl -X POST -d '{"type":"show_databases"}' http://127.0.0.1:8081/query
Sending an image to database:
curl -i -X POST -H "Content-Type: multipart/form-data" \
-F "uploadfile=@image.jpg" \
-F "dbname=database_name" \
-F "key=image_name" \
http://127.0.0.1:8081/upload
Querying an image:
curl -X POST -d '{"type": "select", "params": {"name": "database_name", "field": "key", "key": "image_name"}}' \
http://127.0.0.1:8081/query
Accessing image from browser:
http://localhost:8081/g/database_name/image_key
If is set in database configuration file, generate_token = true, SparrowDB will generate a token for each image uploaded. The token’s value is randomly assigned by and stored in database. The token effectively eliminates attacks aimed at guessing valid URLs for photos.
Accessing image from browser with token:
http://localhost:8081/g/database_name/image_key/token_value
SparrowDB uses bild to allow image processing using LUA script.
All SparrowDB scripts must be in 'scripts' folder.
Example of script that converts image to grayscale:
-- loads sparrowdb module
local s = require("sparrowdb")
-- get image data
image = s.getInputImage()
-- convert image to grayscale
out = s.grayscale(image)
-- set new output for image
s.setOutputImage(out)
This software is under MIT license.