Class: Teems::Services::FileDownloader
- Inherits:
-
Object
- Object
- Teems::Services::FileDownloader
- Defined in:
- lib/teems/services/file_downloader.rb
Overview
Downloads files from pre-authenticated URLs with redirect following
Constant Summary collapse
- MAX_REDIRECTS =
5
Instance Method Summary collapse
- #download(url, output_path) ⇒ Object
-
#initialize(http_client: nil) ⇒ FileDownloader
constructor
A new instance of FileDownloader.
Constructor Details
#initialize(http_client: nil) ⇒ FileDownloader
Returns a new instance of FileDownloader.
9 10 11 |
# File 'lib/teems/services/file_downloader.rb', line 9 def initialize(http_client: nil) @http_client = http_client end |
Instance Method Details
#download(url, output_path) ⇒ Object
13 14 15 16 |
# File 'lib/teems/services/file_downloader.rb', line 13 def download(url, output_path) response = follow_redirects(URI(url)) File.binwrite(output_path, response.body) end |