From e506304b844d67f3860fd127605beb8ba3bc2244 Mon Sep 17 00:00:00 2001 From: Andrei Marcu Date: Mon, 14 Jan 2019 15:23:56 -0800 Subject: [PATCH] Return direct URL in json responses --- display.go | 11 ++++++----- upload.go | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/display.go b/display.go index 70d8dee..ca5bc6f 100644 --- a/display.go +++ b/display.go @@ -52,11 +52,12 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) { if strings.EqualFold("application/json", r.Header.Get("Accept")) { js, _ := json.Marshal(map[string]string{ - "filename": fileName, - "expiry": strconv.FormatInt(metadata.Expiry.Unix(), 10), - "size": strconv.FormatInt(metadata.Size, 10), - "mimetype": metadata.Mimetype, - "sha256sum": metadata.Sha256sum, + "filename": fileName, + "direct_url": getSiteURL(r) + Config.selifPath + fileName, + "expiry": strconv.FormatInt(metadata.Expiry.Unix(), 10), + "size": strconv.FormatInt(metadata.Size, 10), + "mimetype": metadata.Mimetype, + "sha256sum": metadata.Sha256sum, }) w.Write(js) return diff --git a/upload.go b/upload.go index b7195c3..acdd204 100644 --- a/upload.go +++ b/upload.go @@ -295,6 +295,7 @@ func generateBarename() string { func generateJSONresponse(upload Upload, r *http.Request) []byte { js, _ := json.Marshal(map[string]string{ "url": getSiteURL(r) + upload.Filename, + "direct_url": getSiteURL(r) + Config.selifPath + upload.Filename, "filename": upload.Filename, "delete_key": upload.Metadata.DeleteKey, "expiry": strconv.FormatInt(upload.Metadata.Expiry.Unix(), 10),