mirror of
https://github.com/khairul169/garage-webui.git
synced 2025-04-27 22:39:31 +07:00
fix: panic when download file
This commit is contained in:
parent
f30d4289f1
commit
59e68455b6
@ -146,11 +146,20 @@ func (b *Browse) GetOneObject(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", *object.ContentType)
|
||||
w.Header().Set("Content-Length", strconv.FormatInt(*object.ContentLength, 10))
|
||||
w.Header().Set("Cache-Control", "max-age=86400")
|
||||
w.Header().Set("Last-Modified", object.LastModified.Format(time.RFC1123))
|
||||
|
||||
if object.ContentType != nil {
|
||||
w.Header().Set("Content-Type", *object.ContentType)
|
||||
} else {
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
}
|
||||
if object.ContentLength != nil {
|
||||
w.Header().Set("Content-Length", strconv.FormatInt(*object.ContentLength, 10))
|
||||
}
|
||||
if object.ETag != nil {
|
||||
w.Header().Set("Etag", *object.ETag)
|
||||
}
|
||||
|
||||
_, err = io.Copy(w, object.Body)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user