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

Use text/plain as fallback content type for hastebin support

This commit is contained in:
Lukas Schulte Pelkum
2022-01-29 22:17:42 +01:00
parent 6f610a48ec
commit e8e2b49466
4 changed files with 7 additions and 70 deletions

View File

@@ -119,7 +119,7 @@ func (driver *MongoDBDriver) Save(paste *shared.Paste) error {
// Upsert the paste object
filter := bson.M{"_id": paste.ID}
_, err := collection.UpdateOne(ctx, filter, bson.M{"$set": paste,}, options.Update().SetUpsert(true))
_, err := collection.UpdateOne(ctx, filter, bson.M{"$set": paste}, options.Update().SetUpsert(true))
return err
}

View File

@@ -23,15 +23,10 @@ func HastebinSupportHandler(ctx *fasthttp.RequestCtx) {
// Define the paste content
var content string
switch string(ctx.Request.Header.ContentType()) {
case "text/plain":
content = string(ctx.PostBody())
case "multipart/form-data":
if string(ctx.Request.Header.ContentType()) == "multipart/form-data" {
content = string(ctx.FormValue("data"))
default:
ctx.SetStatusCode(fasthttp.StatusBadRequest)
ctx.SetBodyString("invalid content type")
return
} else {
content = string(ctx.PostBody())
}
// Acquire the paste ID