fix: proxy pico media and force svg downloads
This commit is contained in:
parent
441e85194a
commit
09f3268ab5
2 changed files with 16 additions and 1 deletions
|
|
@ -450,6 +450,17 @@ func picoInferAttachmentType(filename, contentType string) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func picoAllowsInlineDisplay(filename, contentType string) bool {
|
||||||
|
contentType = strings.ToLower(strings.TrimSpace(contentType))
|
||||||
|
filename = strings.ToLower(strings.TrimSpace(filename))
|
||||||
|
|
||||||
|
if strings.Contains(contentType, "svg") || filepath.Ext(filename) == ".svg" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return picoInferAttachmentType(filename, contentType) == "image"
|
||||||
|
}
|
||||||
|
|
||||||
func (c *PicoChannel) handleMediaDownload(w http.ResponseWriter, r *http.Request) {
|
func (c *PicoChannel) handleMediaDownload(w http.ResponseWriter, r *http.Request) {
|
||||||
if !c.IsRunning() {
|
if !c.IsRunning() {
|
||||||
http.Error(w, "channel not running", http.StatusServiceUnavailable)
|
http.Error(w, "channel not running", http.StatusServiceUnavailable)
|
||||||
|
|
@ -501,7 +512,7 @@ func (c *PicoChannel) handleMediaDownload(w http.ResponseWriter, r *http.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
dispositionType := "attachment"
|
dispositionType := "attachment"
|
||||||
if picoInferAttachmentType(filename, contentType) == "image" {
|
if picoAllowsInlineDisplay(filename, contentType) {
|
||||||
dispositionType = "inline"
|
dispositionType = "inline"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@ export default defineConfig({
|
||||||
target: "http://localhost:18800",
|
target: "http://localhost:18800",
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
|
"/pico/media": {
|
||||||
|
target: "http://localhost:18800",
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
"/pico/ws": {
|
"/pico/ws": {
|
||||||
target: "ws://localhost:18800",
|
target: "ws://localhost:18800",
|
||||||
ws: true,
|
ws: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue