#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

#960 in Filesystem

Download history 6/week @ 2024-02-16 14/week @ 2024-02-23 5/week @ 2024-03-01 2/week @ 2024-03-08 5/week @ 2024-03-15 57/week @ 2024-03-29

64 downloads per month
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

~23MB
~501K SLoC