|
@ -1,9 +1,11 @@ |
|
|
package main |
|
|
package main |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"encoding/json" |
|
|
"net/http" |
|
|
"net/http" |
|
|
"os" |
|
|
"os" |
|
|
"path" |
|
|
"path" |
|
|
|
|
|
"strconv" |
|
|
"strings" |
|
|
"strings" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
@ -37,6 +39,17 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
|
mimetype := mimemagic.Match("", header) |
|
|
mimetype := mimemagic.Match("", header) |
|
|
|
|
|
|
|
|
|
|
|
if strings.EqualFold("application/json", r.Header.Get("Accept")) { |
|
|
|
|
|
js, _ := json.Marshal(map[string]string{ |
|
|
|
|
|
"filename": fileName, |
|
|
|
|
|
"mimetype": mimetype, |
|
|
|
|
|
"expiry": strconv.FormatInt(expiry, 10), |
|
|
|
|
|
"size": strconv.FormatInt(fileInfo.Size(), 10), |
|
|
|
|
|
}) |
|
|
|
|
|
w.Write(js) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var tpl *pongo2.Template |
|
|
var tpl *pongo2.Template |
|
|
|
|
|
|
|
|
if strings.HasPrefix(mimetype, "image/") { |
|
|
if strings.HasPrefix(mimetype, "image/") { |
|
|