added features and fixes
This commit is contained in:
@@ -119,7 +119,7 @@ func (h *Handler) Upload(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
fmt.Fprintf(w, `{"url":"/%s/%s","size":%d}`, h.bucket, objectName, info.Size)
|
||||
fmt.Fprintf(w, `{"url":"/files/%s","size":%d}`, objectName, info.Size)
|
||||
}
|
||||
|
||||
func (h *Handler) Serve(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -153,6 +153,11 @@ func (h *Handler) Serve(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", stat.ContentType)
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%d", stat.Size))
|
||||
w.Header().Set("Content-Disposition", "attachment")
|
||||
// Inline display for images; attachment for everything else
|
||||
if strings.HasPrefix(stat.ContentType, "image/") {
|
||||
w.Header().Set("Content-Disposition", "inline")
|
||||
} else {
|
||||
w.Header().Set("Content-Disposition", "attachment")
|
||||
}
|
||||
io.Copy(w, obj)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user