summaryrefslogtreecommitdiffstats
path: root/api/file.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2015-07-31 09:16:07 -0400
committerJoram Wilander <jwawilander@gmail.com>2015-07-31 09:16:07 -0400
commitd0865b78b776714139f3a6e39527e00fb05b8ea6 (patch)
tree2580907a7bce3648dc3a00c3effe04a679f22314 /api/file.go
parentc85a852146a7eb079c62917f99663725e9dc06da (diff)
parent2e5528542d532adb81b038cf14c0bae696fec03a (diff)
downloadchat-d0865b78b776714139f3a6e39527e00fb05b8ea6.tar.gz
chat-d0865b78b776714139f3a6e39527e00fb05b8ea6.tar.bz2
chat-d0865b78b776714139f3a6e39527e00fb05b8ea6.zip
Merge pull request #271 from hmhealey/mm1656
MM-1656 Updated file UI
Diffstat (limited to 'api/file.go')
-rw-r--r--api/file.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/api/file.go b/api/file.go
index 3ef50fbbd..219cf6103 100644
--- a/api/file.go
+++ b/api/file.go
@@ -33,7 +33,7 @@ func InitFile(r *mux.Router) {
sr := r.PathPrefix("/files").Subrouter()
sr.Handle("/upload", ApiUserRequired(uploadFile)).Methods("POST")
- sr.Handle("/get/{channel_id:[A-Za-z0-9]+}/{user_id:[A-Za-z0-9]+}/{filename:([A-Za-z0-9]+/)?.+(\\.[A-Za-z0-9]{3,})?}", ApiAppHandler(getFile)).Methods("GET")
+ sr.Handle("/get/{channel_id:[A-Za-z0-9]+}/{user_id:[A-Za-z0-9]+}/{filename:([A-Za-z0-9]+/)?.+(\\.[A-Za-z0-9]{3,})?}", ApiAppHandler(getFile)).Methods("GET", "HEAD")
sr.Handle("/get_public_link", ApiUserRequired(getPublicLink)).Methods("POST")
}
@@ -261,7 +261,10 @@ func getFile(c *Context, w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "max-age=2592000, public")
w.Header().Set("Content-Length", strconv.Itoa(len(f)))
- w.Write(f)
+
+ if r.Method != "HEAD" {
+ w.Write(f)
+ }
}
func asyncGetFile(path string, fileData chan []byte) {