feat: change uploaded filename to uppercase
This commit is contained in:
parent
ae81ead712
commit
f2e38fda23
@ -9,6 +9,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/golang-jwt/jwt/v5"
|
"github.com/golang-jwt/jwt/v5"
|
||||||
)
|
)
|
||||||
@ -73,12 +74,12 @@ func HashFile(file io.Reader, extension string, full bool) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
sha1Hash := hex.EncodeToString(hasher.Sum(nil))
|
sha1Hash := strings.ToUpper(hex.EncodeToString(hasher.Sum(nil)))
|
||||||
filename := fmt.Sprintf("%s%s", sha1Hash, extension)
|
filename := fmt.Sprintf("%s%s", sha1Hash, extension)
|
||||||
if full {
|
if full {
|
||||||
return filename, nil
|
return filename, nil
|
||||||
} else {
|
} else {
|
||||||
return fmt.Sprintf("%s%s", sha1Hash[:8], extension), nil
|
return fmt.Sprintf("%s%s", sha1Hash[:5], extension), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user