Skip to content

Instantly share code, notes, and snippets.

@kkosuge
Created June 19, 2011 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkosuge/1033791 to your computer and use it in GitHub Desktop.
Save kkosuge/1033791 to your computer and use it in GitHub Desktop.
sinatraの簡易Gyazoサーバー
#coding: utf-8
require 'sinatra'
require 'digest/md5'
# 個人用なのでいろいろ削った
# オリジナルとクライアントのソース
# https://github.com/gyazo/Gyazo
post '/example/example/example' do
imagedata = params['imagedata'][:tempfile].read
hash = Digest::MD5.hexdigest(imagedata)[0..2]
File.open("/usr/local/nginx/pic/#{hash}.png","w").print(imagedata)
"http://pic.kksg.net/#{hash}.png"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment