file

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Directory Flag = 0x01

	FilenameRegex string = "^[^/]+$"

	MetadataCreatedAtKey = "created_at"
	MetadataUpdatedAtKey = "updated_at"
	MetadataDeletedAtKey = "deleted_at"
	MetadataSizeKey      = "size"
	MetadataAppKey       = "app"
	MetadataRefKey       = "ref"

	TimestampBase = 16
)
View Source
const (
	MongoFileCollectionName = "files"
)

Variables

This section is empty.

Functions

func NewPermissions

func NewPermissions(userId int32, perm cert.Permission) *proto.Permissions

func NewProtoFile

func NewProtoFile(file *File) *proto.File

Types

type CertificateApplication

type CertificateApplication interface {
	CreateFileAccessCertificate(ctx context.Context, uid int32, file cert.File) (*cert.FileAccessCertificate, error)
}

type Ctrl

type Ctrl uint8

type DirectoryApplication

type DirectoryApplication interface {
	RegisterFile(ctx context.Context, file *File, uid int32, path string) (string, error)
	UnregisterFile(ctx context.Context, file *File, uid int32) error
}

type EventBus

type EventBus interface {
	EmitFileCreated(uid int32, f *File) error
	EmitFileDeleted(uid int32, f *File) error
}

type File

type File struct {
	// contains filtered or unexported fields
}

func NewFile

func NewFile(id string, filename string) (*File, error)

func (*File) AddMetadata

func (file *File) AddMetadata(key string, value string) (old string, exists bool)

func (*File) AddPermission

func (file *File) AddPermission(uid int32, perm cert.Permission)

func (*File) Data

func (file *File) Data() []byte

func (*File) Directory

func (file *File) Directory() string

func (*File) Flags

func (file *File) Flags() Flag

func (*File) Id

func (file *File) Id() string

func (*File) IsContributor

func (file *File) IsContributor(uid int32) bool

func (*File) MarkAsProtected

func (file *File) MarkAsProtected()

func (*File) Metadata

func (file *File) Metadata() Metadata

func (*File) Name

func (file *File) Name() string

func (*File) Owners

func (file *File) Owners() []int32

func (*File) Permission

func (file *File) Permission(uid int32) (perm cert.Permission)

func (*File) ProtectFields

func (file *File) ProtectFields(uid int32)

ProtectFields clear from the file all those fields the given user has no permissions to read.

func (*File) RevokeAccess

func (file *File) RevokeAccess(uid int32) bool

func (*File) RevokePermission

func (file *File) RevokePermission(uid int32, perm cert.Permission)

func (*File) SetDirectory

func (file *File) SetDirectory(dir string)

func (*File) SetFlag

func (file *File) SetFlag(flag Flag)

func (*File) SetID

func (file *File) SetID(id string)

func (*File) SetName

func (file *File) SetName(name string)

func (*File) SharedWith

func (file *File) SharedWith() []int32

func (*File) Value

func (file *File) Value(key string) (value string, exists bool)

type FileApplication

type FileApplication struct {
	// contains filtered or unexported fields
}

func NewFileApplication

func NewFileApplication(repo FileRepository, dirApp DirectoryApplication, certApp CertificateApplication, logger *zap.Logger) *FileApplication

func (*FileApplication) Create

func (app *FileApplication) Create(ctx context.Context, uid int32, fpath string, data []byte, meta Metadata) (*File, error)

func (*FileApplication) Delete

func (app *FileApplication) Delete(ctx context.Context, uid int32, fid string) (*File, error)

func (*FileApplication) Get

func (app *FileApplication) Get(ctx context.Context, uid int32, fid string) (*File, error)

func (*FileApplication) Update

func (app *FileApplication) Update(ctx context.Context, uid int32, fid string, name string, data []byte, meta Metadata) (*File, error)

type FileEventBus

type FileEventBus struct {
	*fb.RabbitMqEventBus
	// contains filtered or unexported fields
}

func NewFileEventBus

func NewFileEventBus(bus *fb.RabbitMqEventBus, exchange string, issuer string) *FileEventBus

func (*FileEventBus) EmitFileCreated

func (bus *FileEventBus) EmitFileCreated(uid int32, f *File) error

func (*FileEventBus) EmitFileDeleted

func (bus *FileEventBus) EmitFileDeleted(uid int32, f *File) error

type FileEventHandler

type FileEventHandler struct {
	// contains filtered or unexported fields
}

func NewFileEventHandler

func NewFileEventHandler(fileApp *FileApplication, certApp *cert.CertificateApplication, logger *zap.Logger) *FileEventHandler

func (*FileEventHandler) DiscardIssuer

func (handler *FileEventHandler) DiscardIssuer(issuer string)

func (*FileEventHandler) OnEvent

func (handler *FileEventHandler) OnEvent(ctx context.Context, body []byte)

type FileEventPayload

type FileEventPayload struct {
	Issuer   string `json:"issuer"`
	UserID   int32  `json:"user_id"`
	AppID    string `json:"app_id"`
	FileName string `json:"file_name"`
	FileID   string `json:"file_id"`
	Kind     string `json:"kind"`
}

type FileGrpcService

type FileGrpcService struct {
	proto.UnimplementedFileServiceServer
	// contains filtered or unexported fields
}

func NewFileGrpcServer

func NewFileGrpcServer(fileApp *FileApplication, certApp *cert.CertificateApplication, bus EventBus, authHeader string, logger *zap.Logger) *FileGrpcService

func (*FileGrpcService) Create

func (server *FileGrpcService) Create(ctx context.Context, req *proto.File) (*proto.File, error)

func (*FileGrpcService) Delete

func (server *FileGrpcService) Delete(ctx context.Context, req *proto.File) (*proto.File, error)

func (*FileGrpcService) Get

func (server *FileGrpcService) Get(ctx context.Context, req *proto.File) (*proto.File, error)

func (*FileGrpcService) Update

func (server *FileGrpcService) Update(ctx context.Context, req *proto.File) (*proto.File, error)

type FileRepository

type FileRepository interface {
	Create(ctx context.Context, file *File) error
	Find(context.Context, string) (*File, error)
	FindAll(context.Context, []string) ([]*File, error)
	Save(ctx context.Context, file *File) error
	Delete(ctx context.Context, file *File) error
}

type Flag

type Flag uint8

type Metadata

type Metadata map[string]string

type MongoFileRepository

type MongoFileRepository struct {
	// contains filtered or unexported fields
}

func NewMongoFileRepository

func NewMongoFileRepository(db *mongo.Database, logger *zap.Logger) *MongoFileRepository

func (*MongoFileRepository) Create

func (repo *MongoFileRepository) Create(ctx context.Context, file *File) error

func (*MongoFileRepository) Delete

func (repo *MongoFileRepository) Delete(ctx context.Context, file *File) error

func (*MongoFileRepository) Find

func (repo *MongoFileRepository) Find(ctx context.Context, id string) (*File, error)

func (*MongoFileRepository) FindAll

func (repo *MongoFileRepository) FindAll(ctx context.Context, ids []string) ([]*File, error)

FindAll returns all those files matching the given ids, excluding the data field

func (*MongoFileRepository) Save

func (repo *MongoFileRepository) Save(ctx context.Context, file *File) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL