base64 encoding and image/png fixed in Header
This commit is contained in:
parent
5d3cf69c90
commit
3459e20be1
@ -161,7 +161,7 @@ function run() {
|
|||||||
req.onreadystatechange = function() {
|
req.onreadystatechange = function() {
|
||||||
switch (req.status) {
|
switch (req.status) {
|
||||||
case 200:
|
case 200:
|
||||||
if (req.getResponseHeader("Content-Type") === "img/png") {
|
if (req.getResponseHeader("Content-Type") === "image/png") {
|
||||||
output.innerHTML = '<img src="data:image/png;base64,' + req.responseText + '"/>';
|
output.innerHTML = '<img src="data:image/png;base64,' + req.responseText + '"/>';
|
||||||
} else {
|
} else {
|
||||||
output.innerHTML = req.responseText;
|
output.innerHTML = req.responseText;
|
||||||
|
1
main.go
1
main.go
@ -76,6 +76,7 @@ func (t *Tool) execute(in io.Reader, w http.ResponseWriter) {
|
|||||||
if e := cmd.Run(); e == nil {
|
if e := cmd.Run(); e == nil {
|
||||||
if t.ContentType != "" {
|
if t.ContentType != "" {
|
||||||
w.Header().Add("Content-Type", t.ContentType)
|
w.Header().Add("Content-Type", t.ContentType)
|
||||||
|
w.Header().Set("Content-Transfer-Encoding", "base64")
|
||||||
io.Copy(base64.NewEncoder(base64.StdEncoding, w), buf)
|
io.Copy(base64.NewEncoder(base64.StdEncoding, w), buf)
|
||||||
} else {
|
} else {
|
||||||
w.Header().Add("Content-Type", "image/svg+xml")
|
w.Header().Add("Content-Type", "image/svg+xml")
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
"Args": ["+O-", "-D", "+A0.9", "+R3"],
|
"Args": ["+O-", "-D", "+A0.9", "+R3"],
|
||||||
"Suffix": ".pov",
|
"Suffix": ".pov",
|
||||||
"NeedsFile": true,
|
"NeedsFile": true,
|
||||||
"ContentType": "img/png",
|
"ContentType": "image/png",
|
||||||
"Description": "Povray, raytracer",
|
"Description": "Povray, raytracer",
|
||||||
"BgColor": "Orange",
|
"BgColor": "Orange",
|
||||||
"Documentation": {
|
"Documentation": {
|
||||||
|
Loading…
Reference in New Issue
Block a user