multipart 0.4.1

A backend-agnostic extension for HTTP libraries that provides support for POST multipart/form-data requests on for both client and server.
docs.rs failed to build multipart-0.4.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: multipart-0.18.0

Multipart + Hyper Build Status On Crates.io

Client- and server-side abstractions for HTTP file uploads (POST requests with Content-Type: multipart/form-data).

Provides integration with Hyper via the hyper feature. More to come!

####Documentation

Usage

In your Cargo.toml:

# Currently only useful with `hyper` and `url` crates:
[dependencies]
hyper = "*"
url = "*"

[dependencies.multipart]
version = "*" # Or use the version in the Crates.io badge above.
# You can also select which features to compile:
# default-features = false
# features = ["hyper", "server", "client"]

Client-side example using Hyper (features = ["hyper", "client"] or default):

extern crate hyper;
extern crate multipart;
extern crate url;

use hyper::client::request::Request;
use hyper::method::Method;

use multipart::client::Multipart;

use url::Url;

fn main() {
    let url = Url::parse("127.0.0.1").unwrap();
    let request = Request::new(Method::Post, url).unwrap();
    
    let mut response = Multipart::from_request(request).unwrap()
        .write_text("hello", "world")
        .write_file("my_file", "my_text_data.txt")
        .send().unwrap();
        
    // Read response...
}

Server-side example using Hyper (features = ["hyper", "server"] or default):

use hyper::net::Fresh;
use hyper::server::{Server, Request, Response};

use multipart::server::Multipart;
use multipart::server::hyper::Switch;

fn handle_regular<'a, 'k>(req: Request<'a, 'k>, res: Response<'a, Fresh>) {
    // handle things here
}

fn handle_multipart<'a, 'k>(mut multi: Multipart<Request<'a, 'k>>, res: Response<'a, Fresh>) {
    multi.foreach_entry(|entry| println!("Multipart entry: {:?}", entry)).unwrap();
}

fn main() {
    Server::http("0.0.0.0:0").unwrap()
      .handle(Switch::new(handle_regular, handle_multipart))
      .unwrap();
}

License

MIT