1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

CLI support! You can use curl (only curl at the moment) to

PUT files into the database.
This commit is contained in:
Zack Scholl
2016-03-28 20:19:13 -04:00
parent f6c287ba24
commit bd59a69f28
4 changed files with 58 additions and 5 deletions

View File

@@ -21,8 +21,17 @@ import (
"github.com/russross/blackfriday"
)
const _24K = (1 << 20) * 24
func putFile(c *gin.Context) {
if isIPBanned(c.ClientIP()) {
c.Data(200, "text/plain", []byte("You are rate limited to 20 requests/hour."))
return
}
filename := c.Param("title")
if len(filename) == 0 {
filename = randomAlliterateCombo()
}
contentLength := c.Request.ContentLength
var reader io.Reader
reader = c.Request.Body
@@ -68,7 +77,6 @@ func putFile(c *gin.Context) {
var p WikiData
p.load(strings.ToLower(filename))
p.save(buf.String())
fmt.Println(c.ClientIP())
c.Data(200, "text/plain", []byte("File uploaded to http://"+RuntimeArgs.ExternalIP+"/"+filename))
}