api: refactor image size in composeImageHandler
The composeImageHandler no longer needs to get the file size for an Image because the image struct now contains the file size.
This commit is contained in:
parent
4366e390cf
commit
eeb657fb5b
1 changed files with 1 additions and 7 deletions
|
|
@ -854,15 +854,9 @@ func (api *API) composeImageHandler(writer http.ResponseWriter, request *http.Re
|
|||
return
|
||||
}
|
||||
|
||||
stat, err := image.File.Stat()
|
||||
if err != nil {
|
||||
statusResponseError(writer, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
writer.Header().Set("Content-Disposition", "attachment; filename="+uuid.String()+"-"+image.Name)
|
||||
writer.Header().Set("Content-Type", image.Mime)
|
||||
writer.Header().Set("Content-Length", fmt.Sprintf("%d", stat.Size()))
|
||||
writer.Header().Set("Content-Length", fmt.Sprintf("%d", image.Size))
|
||||
|
||||
io.Copy(writer, image.File)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue