#http #file #download #local-file

file-fetcher

A library to fetch files either locally or over the net (http)

5 releases

0.1.4 Sep 27, 2019
0.1.3 Sep 27, 2019
0.1.2 Sep 26, 2019
0.1.1 Jul 25, 2017
0.1.0 Jul 25, 2017

#1170 in Filesystem


Used in 2 crates (via libmaj)

MIT license

9KB
113 lines

file_fetcher

The simplest library to get files over http or locally. DISCLAIMER: use reqwest to manage http, so this library is small but its dependencies... not so much.

Cargo.toml dependencies

[dependencies]
file_fetcher = "0.1"

Examples

To load a local file (here ./src/lib.rs)

use std::fs;
use file_fetcher::open_bytes_str;

let path = fs::canonicalize("./src/lib.rs").unwrap();
let local_bytes = open_bytes_str(&format!("file://{}", path.display()))
                  .unwrap();

To load a remote file

use file_fetcher::open_bytes_str;

let remote_bytes = open_bytes_str("https://gitlab.com/Artefaritaj/file-fetcher/raw/master/src/lib.rs")
                    .unwrap();

lib.rs:

The 'file_fetcher' crate can get you file either locally or over http(s).

Dependencies

~21–29MB
~513K SLoC