forked from zitadel/zitadel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.go
52 lines (44 loc) · 1.29 KB
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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 ObjectType = iota
ObjectTypeStyling
)
func (o ObjectType) String() string {
switch o {
case ObjectTypeUserAvatar:
return "0"
case ObjectTypeStyling:
return "1"
default:
return ""
}
}
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
}