-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): allow to override filename when using random_url (#233)
* feat(server): allow to override filename when using random_url * docs(README): remove line from features * refactor(header): make const private
- Loading branch information
Showing
6 changed files
with
160 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ Here you can read the blog post about how it is deployed on Shuttle: [https://bl | |
- [Paste file from remote URL](#paste-file-from-remote-url) | ||
- [Cleaning up expired files](#cleaning-up-expired-files) | ||
- [Delete file from server](#delete-file-from-server) | ||
- [Override the filename when using `random_url`](#override-the-filename-when-using-random_url) | ||
- [Server](#server) | ||
- [List endpoint](#list-endpoint) | ||
- [HTML Form](#html-form) | ||
|
@@ -254,6 +255,14 @@ $ curl -H "Authorization: <auth_token>" -X DELETE "<server_address>/file.txt" | |
|
||
> The `DELETE` endpoint will not be exposed and will return `404` error if `delete_tokens` are not set. | ||
#### Override the filename when using `random_url` | ||
|
||
The generation of a random filename can be overridden by sending a header called `filename`: | ||
|
||
```sh | ||
curl -F "[email protected]" -H "filename: <file_name>" "<server_address>" | ||
``` | ||
|
||
### Server | ||
|
||
To start the server: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[server] | ||
address = "127.0.0.1:8000" | ||
max_content_length = "10MB" | ||
upload_path = "./upload" | ||
|
||
[paste] | ||
random_url = { type = "alphanumeric", length = "4", suffix_mode = true } | ||
default_extension = "txt" | ||
duplicate_files = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
content="test data" | ||
|
||
setup() { | ||
echo "$content" > file | ||
} | ||
|
||
run_test() { | ||
file_url=$(curl -s -F "file=@file" -H "filename:fn_from_header.txt" localhost:8000) | ||
test "$file_url" = "http://localhost:8000/fn_from_header.txt" | ||
test "$content" = "$(cat upload/fn_from_header.txt)" | ||
test "$content" = "$(curl -s $file_url)" | ||
} | ||
|
||
teardown() { | ||
rm file | ||
rm -r upload | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters