Files
fnx_web/webcontroller/misc.go

60 lines
1.7 KiB
Go
Raw Normal View History

2021-01-12 14:07:55 +01:00
package webcontroller
import (
"encoding/base64"
"fmt"
"net/http"
2021-11-16 15:20:15 +01:00
"fornaxian.tech/log"
2021-01-12 14:07:55 +01:00
"github.com/julienschmidt/httprouter"
)
// ServeFileViewerDemo is a dummy API response that responds with info about a
// non-existent demo file. This is required by the a-ads ad network to allow for
// automatic checking of the presence of the ad unit on this page.
func (wc *WebController) serveShareXConfig(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
templateData := wc.newTemplateData(w, r)
w.Header().Add("Content-Disposition", "attachment; filename=pixeldrain.com.sxcu")
if templateData.Authenticated {
sess, err := templateData.PixelAPI.PostUserSession("sharex")
2021-01-12 14:07:55 +01:00
if err != nil {
log.Error("Failed to create user session: %s", err)
2024-09-24 00:12:41 +02:00
wc.templates.Run(w, r, "500", templateData)
2021-01-12 14:07:55 +01:00
return
}
2025-08-22 15:24:10 +02:00
fmt.Fprintf(w,
2021-01-12 14:07:55 +01:00
`{
2025-08-22 15:24:10 +02:00
"Version": "18.0.1",
2021-01-12 14:07:55 +01:00
"DestinationType": "ImageUploader, TextUploader, FileUploader",
2025-08-22 15:24:10 +02:00
"RequestMethod": "PUT",
"RequestURL": "https://pixeldrain.com/api/file/{filename}",
2021-01-12 14:07:55 +01:00
"Headers": {
"Authorization": "Basic %s"
},
2025-08-22 15:24:10 +02:00
"Body": "Binary",
"URL": "https://pixeldrain.com/u/{json:id}",
"ThumbnailURL": "https://pixeldrain.com/api/file/{json:id}/thumbnail",
"DeletionURL": "https://pixeldrain.com/u/{json:id}"
2021-01-12 14:07:55 +01:00
}
`,
base64.StdEncoding.EncodeToString([]byte(
templateData.User.Username+":"+sess.AuthKey.String(),
2025-08-22 15:24:10 +02:00
)))
2021-01-12 14:07:55 +01:00
} else {
2021-09-21 21:39:28 +02:00
w.Write([]byte(
2021-01-12 14:07:55 +01:00
`{
2025-08-22 15:24:10 +02:00
"Version": "18.0.1",
2021-01-12 14:07:55 +01:00
"DestinationType": "ImageUploader, TextUploader, FileUploader",
2025-08-22 15:24:10 +02:00
"RequestMethod": "PUT",
"RequestURL": "https://pixeldrain.com/api/file/{filename}",
"Body": "Binary",
"URL": "https://pixeldrain.com/u/{json:id}",
"ThumbnailURL": "https://pixeldrain.com/api/file/{json:id}/thumbnail"
2021-01-12 14:07:55 +01:00
}
`,
2021-09-21 21:39:28 +02:00
))
2021-01-12 14:07:55 +01:00
}
}