diff --git a/.dockerignore b/.dockerignore index 73269dd..8ca677b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,6 +3,7 @@ /.github/ /upload/ /shuttle/ +/examples/ # Files .gitignore diff --git a/README.md b/README.md index ca459f6..3217d97 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,15 @@ $ rustypaste See [config.toml](./config.toml) for configuration options. +#### HTML Form + +It is possible to use an HTML form for uploading files. To do so, you need to update two fields in your `config.toml`: + +- Set the `landing_page_content_type` to `text/html; charset=utf-8`. +- Update the `landing_page` field with your HTML form. + +For an example, see [examples/html_form.toml](./examples/html_form.toml) + #### Docker Following command can be used to run a container which is built from the [Dockerfile](./Dockerfile) in this repository: diff --git a/examples/html_form.toml b/examples/html_form.toml new file mode 100644 index 0000000..5f1f5b2 --- /dev/null +++ b/examples/html_form.toml @@ -0,0 +1,128 @@ +[config] +refresh_rate = "1s" + +[server] +address = "127.0.0.1:8000" +#url = "https://rustypaste.shuttleapp.rs" +#workers=4 +max_content_length = "10MB" +upload_path = "./upload" +timeout = "30s" +expose_version = false +landing_page = """ + + + rustypaste + + + + +
+┬─┐┬ ┬┌─┐┌┬┐┬ ┬┌─┐┌─┐┌─┐┌┬┐┌─┐
+├┬┘│ │└─┐ │ └┬┘├─┘├─┤└─┐ │ ├┤
+┴└─└─┘└─┘ ┴  ┴ ┴  ┴ ┴└─┘ ┴ └─┘
+the server administrator might remove any pastes that they do not personally
+want to host.
+
+by default, pastes expire every hour.
+        
+

share url

+
+ + +
+ +

share file from url

+
+ + +
+ +

share file

+
+ + +
+ +

share one-time file

+
+ + +
+ + +""" +landing_page_content_type = "text/html; charset=utf-8" + +[paste] +random_url = { enabled = true, type = "petname", words = 2, separator = "-" } +#random_url = { enabled = true, type = "alphanumeric", length = 8 } +default_extension = "txt" +mime_override = [ + { mime = "image/jpeg", regex = "^.*\\.jpg$" }, + { mime = "image/png", regex = "^.*\\.png$" }, + { mime = "image/svg+xml", regex = "^.*\\.svg$" }, + { mime = "video/webm", regex = "^.*\\.webm$" }, + { mime = "video/x-matroska", regex = "^.*\\.mkv$" }, + { mime = "application/octet-stream", regex = "^.*\\.bin$" }, + { mime = "text/plain", regex = "^.*\\.(log|txt|diff|sh|rs|toml)$" }, +] +mime_blacklist = [ + "application/x-dosexec", + "application/java-archive", + "application/java-vm", +] +duplicate_files = true +# default_expiry = "1h" +delete_expired_files = { enabled = true, interval = "1h" }