sparrowdb

command module
v0.0.0-...-99d1211 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2016 License: MIT Imports: 15 Imported by: 0

README

Golang logo

GoDoc Build Status Go Report Card

Whats is SparrowDB?

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 Object Store

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.

Features

  1. Built-in HTTP API so you don't have to write any server side code to get up and running.
  2. Optimizations for image storing.
  3. Websocket server to provide real time information about the server.

Getting started

This short guide will walk you through getting a basic server up and running, and demonstrate some simple reads and writes.

Using Sparrow

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 "[email protected]" \
    -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

Token

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

Image Processing

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)

License

This software is under MIT license.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL