feat: upload

This commit is contained in:
Rogee
2025-01-15 10:43:16 +08:00
parent 9bfdf0e0ea
commit ab827715fb
16 changed files with 378 additions and 161 deletions

View File

@@ -17,8 +17,6 @@ import (
const (
// StorageTypeLocal is a StorageType of type Local.
StorageTypeLocal StorageType = iota
// StorageTypeAliOSS is a StorageType of type AliOSS.
StorageTypeAliOSS
// StorageTypeS3 is a StorageType of type S3.
StorageTypeS3
// StorageTypeMinIO is a StorageType of type MinIO.
@@ -27,13 +25,12 @@ const (
var ErrInvalidStorageType = fmt.Errorf("not a valid StorageType, try [%s]", strings.Join(_StorageTypeNames, ", "))
const _StorageTypeName = "LocalAliOSSS3MinIO"
const _StorageTypeName = "LocalS3MinIO"
var _StorageTypeNames = []string{
_StorageTypeName[0:5],
_StorageTypeName[5:11],
_StorageTypeName[11:13],
_StorageTypeName[13:18],
_StorageTypeName[5:7],
_StorageTypeName[7:12],
}
// StorageTypeNames returns a list of possible string values of StorageType.
@@ -47,17 +44,15 @@ func StorageTypeNames() []string {
func StorageTypeValues() []StorageType {
return []StorageType{
StorageTypeLocal,
StorageTypeAliOSS,
StorageTypeS3,
StorageTypeMinIO,
}
}
var _StorageTypeMap = map[StorageType]string{
StorageTypeLocal: _StorageTypeName[0:5],
StorageTypeAliOSS: _StorageTypeName[5:11],
StorageTypeS3: _StorageTypeName[11:13],
StorageTypeMinIO: _StorageTypeName[13:18],
StorageTypeLocal: _StorageTypeName[0:5],
StorageTypeS3: _StorageTypeName[5:7],
StorageTypeMinIO: _StorageTypeName[7:12],
}
// String implements the Stringer interface.
@@ -76,10 +71,9 @@ func (x StorageType) IsValid() bool {
}
var _StorageTypeValue = map[string]StorageType{
_StorageTypeName[0:5]: StorageTypeLocal,
_StorageTypeName[5:11]: StorageTypeAliOSS,
_StorageTypeName[11:13]: StorageTypeS3,
_StorageTypeName[13:18]: StorageTypeMinIO,
_StorageTypeName[0:5]: StorageTypeLocal,
_StorageTypeName[5:7]: StorageTypeS3,
_StorageTypeName[7:12]: StorageTypeMinIO,
}
// ParseStorageType attempts to convert a string to a StorageType.

View File

@@ -1,15 +1,21 @@
package fields
// swagger:enum UserStatus
// ENUM( Local ,AliOSS, S3, MinIO)
// ENUM( Local, S3, MinIO)
type StorageType int16
type StorageConfig struct {
Path *string `json:"path"`
S3 *StorageS3Config `json:"s3"`
Local *LocalStorage `json:"local"`
S3 *StorageS3Config `json:"s3"`
}
type LocalStorage struct {
Path string `json:"path"`
Host string `json:"host"`
}
type StorageS3Config struct {
Host string `json:"host"`
Endpoint string `json:"endpoint"`
AccessKeyID string `json:"access_key_id"`
AccessKeySecret string `json:"access_key_secret"`

View File

@@ -13,11 +13,11 @@ import (
)
type Storages struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
IsDefault bool `json:"is_default"`
Name string `json:"name"`
Type fields.StorageType `json:"type"`
Config string `json:"config"`
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
IsDefault bool `json:"is_default"`
Name string `json:"name"`
Type fields.StorageType `json:"type"`
Config fields.StorageConfig `json:"config"`
}

View File

@@ -14,6 +14,7 @@ types:
storages:
type: StorageType
config: StorageConfig
posts:
stage: PostStage