3

我找到了一些代码`

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`

如何将响应的内容保存为回形针中的附件?

4

1 回答 1

2

它可能不是您正在寻找的东西,但您可能想查看http://trevorturk.com/2008/12/11/easy-upload-via-url-with-paperclip/

于 2010-08-28T02:47:19.993 回答