Download large files (~ 40 MB) and save as attachments using a paper clip

I 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 can I save the contents of the response as an attachment in a folder?

+3
source share
1 answer

This may not be exactly what you are looking for, but you can check out http://trevorturk.com/2008/12/11/easy-upload-via-url-with-paperclip/ .

+2
source

Source: https://habr.com/ru/post/1712839/


All Articles