Permalink
Browse files

Added server upload.cgi

  • Loading branch information...
1 parent 75fce29 commit fa2f85a38241499d5da15e77914e8b4030cafdb0 Isshu Rakusai committed Nov 11, 2009
Showing with 23 additions and 0 deletions.
  1. +23 −0 Server/upload.cgi
View
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+# -*- ruby -*-
+#
+# $Date$
+# $Rev$
+#
+require 'cgi'
+require 'digest/md5'
+require 'sdbm'
+
+cgi = CGI.new("html3")
+
+id = cgi.params['id'][0].read
+imagedata = cgi.params['imagedata'][0].read
+hash = Digest::MD5.new(imagedata).to_s
+
+dbm = SDBM.open('db/id',0644)
+dbm[hash] = id
+dbm.close
+
+File.open("data/#{hash}.png","w").print(imagedata)
+
+cgi.out { "http://gyazo.com/#{hash}.png" }

0 comments on commit fa2f85a

Please sign in to comment.