mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
19 lines
485 B
Go
19 lines
485 B
Go
package filemanager
|
|
|
|
import "net/http"
|
|
|
|
// serveChecksum calculates the hash of a file. Supports MD5, SHA1, SHA256 and SHA512.
|
|
func serveChecksum(c *requestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
|
query := r.URL.Query().Get("checksum")
|
|
|
|
val, err := c.fi.Checksum(query)
|
|
if err == errInvalidOption {
|
|
return http.StatusBadRequest, err
|
|
} else if err != nil {
|
|
return http.StatusInternalServerError, err
|
|
}
|
|
|
|
w.Write([]byte(val))
|
|
return http.StatusOK, nil
|
|
}
|