Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save WWW::Mechanize::File to disk using FileUtils

Tags:

ruby

mechanize

Using Mechanize with Ruby I get a certain file using agent.get('http://example.com/foo.torrent'), with FileUtils or otherwise, how do I save this file to my hard drive (for instance, in a directory wherefrom the script is running)?

P.S. class => WWW::Mechanize::File

like image 538
arentweallhorses Avatar asked Dec 11 '25 12:12

arentweallhorses


1 Answers

Well, WWW::Mechanize::File has a save_as instance method, so I suppose something like this might work:

agent.get('http://example.com/foo.torrent').save_as 'a_file_name'
like image 104
DigitalRoss Avatar answered Dec 13 '25 02:12

DigitalRoss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!