Skip to content

photoshelf/photoshelf-storage

Repository files navigation

photoshelf-storage

Build Status Go Report Card Coverage Status MIT License

Image upload server with REST API.

Run Server

Using Docker

docker run photoshelf/photoshelf-storage

Locally

build executable file.

git clone https://github.com/photoshelf/photoshelf-storage.git
cd photoshelf-storage
dep ensure
go build -o photoshelf-storage

and run

./photoshelf-storage

If you have already set $GOPATH, you can install it with the following command.

go get -u github.com/photoshelf/photoshelf-storage

Running options

flag description default
c configuration file path
p port number 1323
t storage type boltdb
s storage path ./photos

configuration file

photoshelf-storage can recognized external file.
It needs YAML format

server:
  port: 8080
storage:
  type: file
  path: /path/to/storage

storage type

You can use file or embedded kvs (leveldb or boltdb) to store photos.

Using Docker

git clone https://github.com/photoshelf/photoshelf-storage.git
cd photoshelf-storage
docker build -t photoshelf/photoshelf-storage .
docker run -p 1323:1323 -v $PWD/photos:/photoshelf/photos photoshelf/photoshelf-storage

CRUD photo

Create

curl -X POST http://localhost:1323/photos/ -F "photo=@/path/to/photo"

returns

{
  "id": "identifier"
}

Read

curl -X GET http://localhost:1323/photos/:id

or

Access with browser to http://localhost:1323/photos/:id

Update

curl -X PUT http://localhost:1323/photos/:id -F "photo=@/path/to/new_photo"

Delete

curl -X DELETE http://localhost:1323/photos/:id

License

MIT License

Copyright (c) 2017 Shunsuke Maeda

See LICENSE file