blob: 763a91c01f6a95c3e236bce4c2cce5b419f3ee93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
use anyhow::Result;
use download::DownloadInfo;
use download::Downloader;
/// This example shows how to use the `downlaoder`.
#[tokio::main]
async fn main() -> Result<()> {
// Create Download metadata.
let url_data = DownloadInfo::new(
"https://file-examples-com.github.io/uploads/2017/02/file_example_CSV_5000.csv",
);
// Create downloader instance with desired file path and target directory.
let downloader = Downloader::new("test_download", &None, "/tmp");
// Call `download` method to get data from url.
downloader.download(&url_data).await?;
// Call cleanup method to remove downloaded file if no longer necessary.
downloader.cleanup().await?;
Ok(())
}
|