20 lines
490 B
Go
20 lines
490 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"fmt"
|
|
"math/big"
|
|
"path/filepath"
|
|
)
|
|
|
|
// --------------------------------------------
|
|
// FILES NAMES
|
|
// --------------------------------------------
|
|
|
|
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)
|
|
}
|