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:
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user