Private gyazo server on sinatra

Posted by on April 22, 2014 in Ruby, Tech

要約:
Private gyazo server on sinatra

Project

What is this?

This is a private gyazo server works on sinatra.
It provides not only gyazo server function but also image gallery.

Requirements

  • Sinatra (includes WEBrick)
  • Rack (interface between sinatra and nginx)
  • Nginx (or other reverse-proxy/web-server)

Procedure

Gyazo server

Nginx only works as a reverse proxy.
Upload procedure

Image gallery

Dynamic contents and static contents are provided by sinatra and nginx respectively.
Download procedure

Difference between official and mine

File name

Official gyazo names image files based on MD5 hash.
Mine creates 3-chars name (e.g. abc.png, 012.png, etc.) by using this function.

Authentication

Official gyazo allows every users to upload images.
In contrast, mine allows only a user who registered in a config file.