download v0.0.4 Download View Source

Link to this section Summary

Link to this section Functions

subj.

Returns:

  • { :ok, stored_file_absolute_path } if everything were ok.
  • { :error, :file_size_is_too_big } if file size exceeds max_file_size
  • { :error, :download_failure } if host isn’t reachable
  • { :error, :eexist } if file exists already

Options:

  • max_file_size - max available file size for downloading (in bytes). Default is 1024 * 1024 * 1000 (1GB)
  • path - absolute file path for the saved file. Default is pwd <> requested file name

Examples

iex> Download.from("http://speedtest.ftp.otenet.gr/files/test100k.db")
{ :ok, "/absolute/path/to/test_100k.db" }

iex> Download.from("http://speedtest.ftp.otenet.gr/files/test100k.db", [max_file_size: 99 * 1000])
{ :error, :file_size_is_too_big }

iex> Download.from("http://speedtest.ftp.otenet.gr/files/test100k.db", [path: "/custom/absolute/file/path.db"])
{ :ok, "/custom/absolute/file/path.db" }