下载大文件(~40MB)并使用回形针保存为附件

时间:2009-07-17 07:25:18

标签: ruby-on-rails http file paperclip

我找到了一些代码`

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`

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

1 个答案:

答案 0 :(得分:2)

这可能不是您正在寻找的内容,但您可能需要查看http://trevorturk.com/2008/12/11/easy-upload-via-url-with-paperclip/