Files
projet_gestion_commande/backend/gestion/utils/utils.go
T
Nuxgrid 4de42cff57
Backend - Build & Lint / build (push) Failing after 28m23s
chore: build
2026-07-12 15:20:53 +02:00

16 lines
362 B
Go

package utils
import (
"crypto/rand"
"fmt"
"math/big"
"path/filepath"
)
func GenerateUniqueFileName(productName string, originalFileName string) string {
n, _ := rand.Int(rand.Reader, big.NewInt(1000000))
randomString := fmt.Sprintf("%d", n.Int64())
ext := filepath.Ext(originalFileName)
return fmt.Sprintf("%s_%s%s", productName, randomString, ext)
}