- Move box ID validation, file listing/pathing, manifest creation, and uploads to `boxstore` - Use shared helpers for safe filenames and polling interval env parsing - Add file status constants to `models` to avoid duplicated magic strings across handlersrefactor(server): use boxstore helpers and file status consts - Move box ID validation, file listing/pathing, manifest creation, and uploads to `boxstore` - Use shared helpers for safe filenames and polling interval env parsing - Add file status constants to `models` to avoid duplicated magic strings across handlers
31 lines
497 B
Go
31 lines
497 B
Go
package helpers
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
"strings"
|
|
)
|
|
|
|
func RandomHexID(byteCount int) (string, error) {
|
|
bytes := make([]byte, byteCount)
|
|
if _, err := rand.Read(bytes); err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return hex.EncodeToString(bytes), nil
|
|
}
|
|
|
|
func ValidLowerHexID(value string, length int) bool {
|
|
if len(value) != length {
|
|
return false
|
|
}
|
|
|
|
for _, character := range value {
|
|
if !strings.ContainsRune("0123456789abcdef", character) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|