getting user; mod: avatar, profileBg, profile now working
This commit is contained in:
+17
-8
@@ -33,20 +33,29 @@ const (
|
||||
UserProfileBgPrefix DataTypePrefix = "userProfileBg/"
|
||||
)
|
||||
|
||||
func GetKey(connectionId uuid.UUID, mimeType string, uploadType DataType) string {
|
||||
extensions, err := mime.ExtensionsByType(mimeType)
|
||||
type GetKeyOptions struct {
|
||||
UserId uuid.UUID
|
||||
ConnectionId uuid.UUID
|
||||
MimeType string
|
||||
UploadType DataType
|
||||
}
|
||||
|
||||
func GetKey(opts GetKeyOptions) string {
|
||||
extensions, err := mime.ExtensionsByType(opts.MimeType)
|
||||
if err != nil || len(extensions) == 0 {
|
||||
extensions = []string{".unknown"}
|
||||
}
|
||||
|
||||
key := connectionId.String() + "/" + strconv.FormatInt(time.Now().UnixMilli(), 10) + extensions[0]
|
||||
key := "/" + strconv.FormatInt(time.Now().UnixMilli(), 10) + extensions[0]
|
||||
|
||||
if uploadType == UserAvatar {
|
||||
return string(UserAvatarPrefix) + key
|
||||
} else if uploadType == UserProfileBg {
|
||||
return string(UserProfileBgPrefix) + key
|
||||
switch opts.UploadType {
|
||||
case UserAvatar:
|
||||
return string(UserAvatarPrefix) + opts.UserId.String() + key
|
||||
case UserProfileBg:
|
||||
return string(UserProfileBgPrefix) + opts.UserId.String() + key
|
||||
default:
|
||||
return string(FilePrefix) + opts.ConnectionId.String() + key
|
||||
}
|
||||
return string(FilePrefix) + key
|
||||
}
|
||||
|
||||
func Init(ctx context.Context) {
|
||||
|
||||
Reference in New Issue
Block a user