mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-08 09:13:13 +03:00
34 lines
705 B
Go
34 lines
705 B
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
TypeFileSystem = "filesystem"
|
|
TypeS3 = "s3"
|
|
)
|
|
|
|
type ObjectInfo struct {
|
|
Path string
|
|
Size int64
|
|
ModTime time.Time
|
|
}
|
|
|
|
type FileStorage interface {
|
|
Save(ctx context.Context, relativePath string, data io.Reader) error
|
|
Open(ctx context.Context, relativePath string) (io.ReadCloser, int64, error)
|
|
Delete(ctx context.Context, relativePath string) error
|
|
DeleteAll(ctx context.Context, prefix string) error
|
|
List(ctx context.Context, prefix string) ([]ObjectInfo, error)
|
|
Walk(ctx context.Context, root string, fn func(ObjectInfo) error) error
|
|
Type() string
|
|
}
|
|
|
|
func IsNotExist(err error) bool {
|
|
return os.IsNotExist(err)
|
|
}
|