Skip to content

Instantly share code, notes, and snippets.

@dru
Created December 26, 2018 13:00
Show Gist options
  • Save dru/7e29eec44230aa6d455d1c52881116eb to your computer and use it in GitHub Desktop.
Save dru/7e29eec44230aa6d455d1c52881116eb to your computer and use it in GitHub Desktop.
Minimal upload server on Rust 2018
[package]
name = "server"
version = "0.1.0"
edition = "2018"
[dependencies]
rocket = "^0.4.0"
[global.limits]
forms = 314572800
[global]
address = "0.0.0.0"
#![feature(proc_macro_hygiene, decl_macro)]
#[cfg(test)] mod tests;
use rocket::{routes, post, Data};
use std::io;
#[post("/upload", data = "<data>")]
fn upload(data: Data) -> io::Result<String> {
data.stream_to_file("upload.data").map(|n| n.to_string())
}
fn main() {
rocket::ignite().mount("/", routes![upload]).launch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment