Created
June 19, 2011 05:28
-
-
Save kkosuge/1033791 to your computer and use it in GitHub Desktop.
sinatraの簡易Gyazoサーバー
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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