TODO 各种格式
This commit is contained in:
parent
3b462edc89
commit
70fd711fa5
|
@ -193,12 +193,6 @@ func RequestFileParse(r *http.Request, req any) error {
|
||||||
|
|
||||||
field := reqValue.Field(i)
|
field := reqValue.Field(i)
|
||||||
|
|
||||||
// aa1:
|
|
||||||
// field.Field(0).Set(fheader.Filename)
|
|
||||||
// field.Field(1).Set( fheader.Header)
|
|
||||||
// field.Field(2).Set( fheader.Size)
|
|
||||||
// field.Field(3).Set( data)
|
|
||||||
|
|
||||||
if field.Kind() == reflect.Ptr {
|
if field.Kind() == reflect.Ptr {
|
||||||
if field.IsNil() {
|
if field.IsNil() {
|
||||||
fsfile := reflect.New(field.Type().Elem())
|
fsfile := reflect.New(field.Type().Elem())
|
||||||
|
|
|
@ -2,18 +2,15 @@ package check
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fusenapi/utils/format"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var category = map[string]bool{
|
|
||||||
"personalization": true,
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckCategory 检查是否存在该类型
|
// CheckCategory 检查是否存在该类型
|
||||||
func CheckCategory(key string) bool {
|
func CheckCategory(key string) bool {
|
||||||
_, ok := category[key]
|
_, ok := format.CategoryMap[key]
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,22 @@ const (
|
||||||
TypeS3KeyGuest TypeFormatS3KeyName = 2 // 游客
|
TypeS3KeyGuest TypeFormatS3KeyName = 2 // 游客
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type TypeCategory string
|
||||||
|
|
||||||
|
const TCategoryPersonalization TypeCategory = "personalization"
|
||||||
|
const TCategory3DTools TypeCategory = "3dtools"
|
||||||
|
const TCategoryQuotation TypeCategory = "quotation"
|
||||||
|
const TCategoryRenderMegre TypeCategory = "render_megre"
|
||||||
|
|
||||||
|
var CategoryMap = map[string]bool{
|
||||||
|
string(TCategoryPersonalization): true,
|
||||||
|
string(TCategory3DTools): true,
|
||||||
|
string(TCategoryQuotation): true,
|
||||||
|
string(TCategoryRenderMegre): true,
|
||||||
|
}
|
||||||
|
|
||||||
// FormatS3KeyName 需要输入选
|
// FormatS3KeyName 需要输入选
|
||||||
func FormatS3KeyName(keytype TypeFormatS3KeyName, uid int64, now time.Time, env, category, name string) string {
|
func FormatS3KeyName(keytype TypeFormatS3KeyName, uid int64, now time.Time, env string, category TypeCategory, name string) string {
|
||||||
if keytype == TypeS3KeyUser {
|
if keytype == TypeS3KeyUser {
|
||||||
return FormatS3KeyNameUser(uid, now, env, category, name)
|
return FormatS3KeyNameUser(uid, now, env, category, name)
|
||||||
} else if keytype == TypeS3KeyGuest {
|
} else if keytype == TypeS3KeyGuest {
|
||||||
|
@ -25,7 +39,7 @@ func FormatS3KeyName(keytype TypeFormatS3KeyName, uid int64, now time.Time, env,
|
||||||
}
|
}
|
||||||
|
|
||||||
// FormatS3KeyNameUser
|
// FormatS3KeyNameUser
|
||||||
func FormatS3KeyNameUser(userid int64, now time.Time, env, category, name string) string {
|
func FormatS3KeyNameUser(userid int64, now time.Time, env string, category TypeCategory, name string) string {
|
||||||
year, month, _ := now.Date()
|
year, month, _ := now.Date()
|
||||||
names := strings.Split(name, ".")
|
names := strings.Split(name, ".")
|
||||||
var ext string
|
var ext string
|
||||||
|
@ -35,11 +49,17 @@ func FormatS3KeyNameUser(userid int64, now time.Time, env, category, name string
|
||||||
name = names[0]
|
name = names[0]
|
||||||
ext = names[1]
|
ext = names[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch category {
|
||||||
|
case TCategoryPersonalization:
|
||||||
|
// TODO:
|
||||||
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("/%s/%s/%d/%04d%02d/%s_%d.%s", env, category, userid, year, int(month), name, now.Unix(), ext)
|
return fmt.Sprintf("/%s/%s/%d/%04d%02d/%s_%d.%s", env, category, userid, year, int(month), name, now.Unix(), ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FormatS3KeyNameGuest 游客的格式化存储
|
// FormatS3KeyNameGuest 游客的格式化存储
|
||||||
func FormatS3KeyNameGuest(guestid int64, now time.Time, env, category, name string) string {
|
func FormatS3KeyNameGuest(guestid int64, now time.Time, env string, category TypeCategory, name string) string {
|
||||||
year, month, _ := now.Date()
|
year, month, _ := now.Date()
|
||||||
names := strings.Split(name, ".")
|
names := strings.Split(name, ".")
|
||||||
var ext string
|
var ext string
|
||||||
|
|
Loading…
Reference in New Issue
Block a user