Download (chunk_download v0.0.1) View Source

Link to this section Summary

Functions

Downloads the file from a remote url in chunks.

Link to this section Functions

Link to this function

get_file(url, headers, opts \\ [])

View Source

Specs

get_file(binary(), any(), keyword()) :: any()

Downloads the file from a remote url in chunks.

Returns: {:ok, path} if file successfully downloaded {:error, :eexist} if the distination file already exists {:error, :file_is_too_large} if the remote file's size is greater than max_file_size {:error, reason} if the file can't be downloaded or open with a reason

Examples:

# Without headers
Download.get_file(file_url, %{}, path: temp_path)

# With headers, will use default path to save file
Download.get_file(file_url, %{}, path: temp_path)

# With provided path
Download.get_file(file_url, %{"api-key" => "abc"}, path: my_path)

# With max_file_size provided
Download.get_file(file_url, %{"api-key" => "abc"}, path: my_path, max_file_size: 80_000_000)