views:

168

answers:

1

I have found some code `

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`

How I can save the contents of the response as an attachment in paperclip ?

+2  A: 

It may not be exactly what you're looking for but you might want to check out http://trevorturk.com/2008/12/11/easy-upload-via-url-with-paperclip/.

aNoble
This is exactly what I was looking for. Take my money, sir! :)
Erik Escobedo
Ok... It says I need to wait 19 more hours... :(
Erik Escobedo