1

I've been trying to figure out how to use the Down gem to do restartable downloads in ruby.

So the scenario is downloading a large file over an unreliable link. The script should download as much of the file as it can in the timeout allotted (say it's a 5GB file, and the script is given 30 seconds). I would like that 30 second progress (partial file) to be saved so that next time the script is run, it will download another 30 seconds worth. This can happen until the complete file is downloaded and the partial file is turned into a complete file.

I feel like everything i need to accomplish this is in this gem, but it's unclear to me which features i should be using, and how much of it i need to code myself. (streaming? or caching?) I'm a ruby beginner, so i'm guessing i use the caching and just save the progress to a file myself, and enumerate for as many times as i have time.

How would you solve the problem? Would you use a different gem/method?

Luca Kiebel
  • 9,790
  • 7
  • 29
  • 44
aae42
  • 11
  • 2
  • Just an FYI, since nobody's explaining why you're getting "close" votes: This kind of broad "looking for general consultation" question isn't suited for SO, which is built around a direct question/direct answer format. – Kache Aug 18 '20 at 18:39

1 Answers1

1

You probably don't need to build that yourself. Existing tools like curl and wget already have that functionality.

If you really want to build it yourself, you could perhaps take a look at how curl and wget do it (they're open-source, after all) and implement the same in Ruby.

Kache
  • 15,647
  • 12
  • 51
  • 79