Compare commits
No commits in common. "343af57742fe9889939d72b26de6936ab9bc958b" and "6a2bf1ea4a10fc7555dcf21d4b145b9e119a39e2" have entirely different histories.
343af57742
...
6a2bf1ea4a
@ -78,8 +78,6 @@ abyss is a basic and mostly single user http server written in go made for uploa
|
|||||||
curl -F "file=@/path/to/file" -H "X-Auth: "$(cat /path/to/.key) http://localhost:3235/
|
curl -F "file=@/path/to/file" -H "X-Auth: "$(cat /path/to/.key) http://localhost:3235/
|
||||||
```
|
```
|
||||||
|
|
||||||
- it is also possible to add a `-Fsecret=` to your POST to make filenames bigger and harder to guess.
|
|
||||||
|
|
||||||
- you should probably create an `alias` or a `function` to do this automatically for you.
|
- you should probably create an `alias` or a `function` to do this automatically for you.
|
||||||
<details>
|
<details>
|
||||||
<summary>click for an example for bash/zsh:</summary>
|
<summary>click for an example for bash/zsh:</summary>
|
||||||
|
11
handlers.go
11
handlers.go
@ -160,10 +160,6 @@ func (app *Application) formHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
filename := app.publicURL(file, ".txt")
|
filename := app.publicURL(file, ".txt")
|
||||||
|
|
||||||
if len(r.Form["secret"]) == 0 {
|
|
||||||
filename = filename[:8]
|
|
||||||
}
|
|
||||||
|
|
||||||
// reopening file because hash consumes it
|
// reopening file because hash consumes it
|
||||||
file, err = os.Open("/tmp/file.txt")
|
file, err = os.Open("/tmp/file.txt")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -200,10 +196,6 @@ func (app *Application) curlHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
filename := app.publicURL(file, filepath.Ext(handler.Filename))
|
filename := app.publicURL(file, filepath.Ext(handler.Filename))
|
||||||
|
|
||||||
if len(r.Form["secret"]) == 0 {
|
|
||||||
filename = filename[:8]
|
|
||||||
}
|
|
||||||
|
|
||||||
// reopen the file for copying, as the hash process consumed the file reader
|
// reopen the file for copying, as the hash process consumed the file reader
|
||||||
file, _, err = r.FormFile("file")
|
file, _, err = r.FormFile("file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -212,7 +204,8 @@ func (app *Application) curlHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
if err = SaveFile(app.lastUploadedFile, file); err != nil {
|
err = SaveFile(app.lastUploadedFile, file)
|
||||||
|
if err != nil {
|
||||||
fmt.Fprintf(w, "Error parsing file: %s", err.Error())
|
fmt.Fprintf(w, "Error parsing file: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user