How do I download a file over HTTP using Ruby?

后端 未结 5 1203
南笙
南笙 2021-02-07 04:12

How do I download a file over HTTP using Ruby?

5条回答
  •  不要未来只要你来
    2021-02-07 04:15

    Probably the shortest way to download a file:

    require 'open-uri'
    download = open('http://example.com/download.pdf')
    IO.copy_stream(download, '~/my_file.pdf')
    

提交回复
热议问题