main pico / pkg / shared / bucket.go
Antonio Mika  ·  2026-10-10
 1package shared
 2
 3import (
 4	"fmt"
 5	"os"
 6	"path/filepath"
 7	"strings"
 8
 9	"github.com/picosh/pico/pkg/send/utils"
10)
11
12func GetAssetBucketName(userID string) string {
13	return fmt.Sprintf("static-%s", userID)
14}
15
16func GetProjectName(entry *utils.FileEntry) string {
17	if entry.Mode.IsDir() && strings.Count(entry.Filepath, string(os.PathSeparator)) == 0 {
18		return entry.Filepath
19	}
20
21	dir := filepath.Dir(entry.Filepath)
22	list := strings.Split(dir, string(os.PathSeparator))
23	if len(list) == 0 {
24		return ""
25	} else if len(list) == 1 {
26		return list[0]
27	}
28	return list[1]
29}
30
31func GetAssetFileName(entry *utils.FileEntry) string {
32	return entry.Filepath
33}