astropanic
astropanic

Reputation: 10939

Downloading big files (~40MB) and saving as attachments with paperclip

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 ?

Upvotes: 3

Views: 412

Answers (1)

aNoble
aNoble

Reputation: 7072

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/.

Upvotes: 2

Related Questions