28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/pig-media-server/web.rb', line 28
def self.post url, point
imagedata = url.sub(/data:image\/png;base64,/, '').unpack('m').first
boundary = '----BOUNDARYBOUNDARY----'
id = rand(256**16).to_s(16)
data = "--\#{boundary}\\r\ncontent-disposition: form-data; name=\"id\"\\r\n\\r\n\#{id}\\r\n--\#{boundary}\\r\ncontent-disposition: form-data; name=\"imagedata\"; filename=\"gyazo.com\"\\r\n\\r\n\#{imagedata}\\r\n--\#{boundary}--\\r\n"
={
'Content-Length' => data.length.to_s,
'Content-type' => "multipart/form-data; boundary=#{boundary}",
'User-Agent' => 'ssig33.com/1.0'
}
proxy_host, proxy_port = nil, nil
uri = URI.parse point
Net::HTTP::Proxy(proxy_host, proxy_port).start(uri.host,80) {|http|
res = http.post(uri.path, data, ).body
puts res
return res
}
end
|