diff --git a/Cargo.toml b/Cargo.toml index fcdb1ba..006b958 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,16 +4,9 @@ version = "0.1.0" authors = ["Gunwant Jain "] edition = "2018" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] rand = "0.8.0" rocket = "0.4.6" rocket_contrib = { version = "0.4.6", features = ["tera_templates"] } tree_magic = "0.2.3" -# [dependencies.rocket_contrib] -# version = "0.4.6" -# default-features = false -# features = ["tera_templates"] - diff --git a/src/main.rs b/src/main.rs index 1d34221..1cfb05b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,8 +8,8 @@ use std::collections::HashMap; use std::path::Path; use std::fs::File; -use rocket::Data; use rocket_contrib::templates::Template; +use rocket::Data; mod paste_id; @@ -51,6 +51,8 @@ fn upload(paste: Data) -> Result { let filename = format!("upload/{id}", id = id); let filepath = Path::new(&filename); + //TODO: Implement limits when this stupid framework starts working + // Look into using open(), take() methods in the Data struct paste.stream_to_file(filepath)?; let url = match tree_magic::from_filepath(filepath).as_str().contains("text") { @@ -85,17 +87,17 @@ fn index() -> &'static str { Paste a file named 'file.txt' using cURL: - curl --data-binary @file.txt https://bin.example.com + curl -d@file.txt https://bin.wantguns.dev Paste from stdin using cURL: - echo \"Hello, world.\" | curl --data-binary @- https://bin.example.com + echo \"Hello, world.\" | curl -d@- https://bin.wantguns.dev Add this to your .zshrc to implement a quicker usage. function paste() { local file=${1:-/dev/stdin} - curl --data-binary @${file} https://paste.rs + curl -d@${file} https://bin.wantguns.dev } If the uploaded data binary is parsed as \"text/*\", then the paste will be syntax