2009-07-17 24 views
3

で添付ファイルとして保存し、私はいくつかのコード私がペーパークリップの添付ファイルとしてレスポンスの内容を保存することができますどのように `大きなファイル(〜40メガバイト)をダウンロードし、クリップ

require 'socket' 
host = "download.thinkbroadband.com" 
path = "/1GB.zip" # get 1gb sample file 
request = "GET #{path} HTTP/1.0\r\n\r\n" 
socket = TCPSocket.open(host,80) 
socket.print(request) 

# find beginning of response body 
buffer = "" 
while !buffer.match("\r\n\r\n") do 
    buffer += socket.read(1) 
end 

response = socket.read(100) #read first 100 bytes of body 
puts response` 

を発見しましたか?

答えて

関連する問題