mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
dcac08b1d5
* fix: caching of assets (correct headers and versioned avatar url) * serve variables.css versioned and extend shared max age of assets * fix TestCommandSide_AddHumanAvatar * refactor: const types * refactor: return values Co-authored-by: Fabi <38692350+hifabienne@users.noreply.github.com> Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package static
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"io"
|
|
"time"
|
|
)
|
|
|
|
type CreateStorage func(client *sql.DB, rawConfig map[string]interface{}) (Storage, error)
|
|
|
|
type Storage interface {
|
|
PutObject(ctx context.Context, instanceID, location, resourceOwner, name, contentType string, objectType ObjectType, object io.Reader, objectSize int64) (*Asset, error)
|
|
GetObject(ctx context.Context, instanceID, resourceOwner, name string) ([]byte, func() (*Asset, error), error)
|
|
GetObjectInfo(ctx context.Context, instanceID, resourceOwner, name string) (*Asset, error)
|
|
RemoveObject(ctx context.Context, instanceID, resourceOwner, name string) error
|
|
RemoveObjects(ctx context.Context, instanceID, resourceOwner string, objectType ObjectType) error
|
|
//TODO: add functionality to move asset location
|
|
}
|
|
|
|
type ObjectType int32
|
|
|
|
const (
|
|
ObjectTypeUserAvatar = iota
|
|
ObjectTypeStyling
|
|
)
|
|
|
|
type Asset struct {
|
|
InstanceID string
|
|
ResourceOwner string
|
|
Name string
|
|
Hash string
|
|
Size int64
|
|
LastModified time.Time
|
|
Location string
|
|
ContentType string
|
|
}
|
|
|
|
func (a *Asset) VersionedName() string {
|
|
return a.Name + "?v=" + a.Hash
|
|
}
|