file

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDocumentNotFound is returned when the doc does not exist in the DB.
	ErrDocumentNotFound = "document not found"
)

Functions

func RegisterHandlers

func RegisterHandlers(g *echo.Group, service Service,
	requireLogin echo.MiddlewareFunc, logger log.Logger)

Types

type CreateFileRequest

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

CreateFileRequest represents a file creation request.

type File

type File struct {
	entity.File
}

File represents the data about a File.

type Producer

type Producer interface {
	Produce(string, []byte) error
}

Producer represents event stream message producer interface.

type Repository

type Repository interface {
	// Get returns the file with the specified file ID.
	Get(ctx context.Context, id string, fields []string) (entity.File, error)
	// Count returns the number of files.
	Count(ctx context.Context) (int, error)
	// Query returns the list of files with the given offset and limit.
	Query(ctx context.Context, offset, limit int) ([]entity.File, error)
	// Create saves a new file in the storage.
	Create(ctx context.Context, id string, file entity.File) error
	// Update updates the whole file with given ID in the storage.
	Update(ctx context.Context, key string, file entity.File) error
	// Patch patches a sub entry in the file with given ID in the storage.
	Patch(ctx context.Context, key, path string, val interface{}) error
	// Delete removes the file with given ID from the storage.
	Delete(ctx context.Context, id string) error
	// DeleteActivity removes the activity given its kind and target.
	DeleteActivity(ctx context.Context, kind, username, target string) error
}

Repository encapsulates the logic to access files from the data source.

func NewRepository

func NewRepository(db *dbcontext.DB, logger log.Logger) Repository

NewRepository creates a new file repository.

type Securer

type Securer interface {
	Hash([]byte) string
}

Securer represents security interface.

type Service

type Service interface {
	Get(ctx context.Context, id string, fields []string) (File, error)
	Count(ctx context.Context) (int, error)
	Create(ctx context.Context, input CreateFileRequest) (File, error)
	Update(ctx context.Context, id string, input UpdateFileRequest) (File, error)
	Delete(ctx context.Context, id string) (File, error)
	Query(ctx context.Context, offset, limit int) ([]File, error)
	Like(ctx context.Context, id string) error
	Unlike(ctx context.Context, id string) error
	Rescan(ctx context.Context, id string) error
}

Service encapsulates usecase logic for files.

func NewService

func NewService(repo Repository, logger log.Logger, sec Securer,
	updown UploadDownloader, producer Producer, topic, bucket string,
	userSvc user.Service, actSvc activity.Service) Service

NewService creates a new File service.

type UpdateFileRequest

type UpdateFileRequest struct {
	MD5         string                 `json:"md5,omitempty"`
	SHA1        string                 `json:"sha1,omitempty"`
	SHA256      string                 `json:"sha256,omitempty"`
	SHA512      string                 `json:"sha512,omitempty"`
	Ssdeep      string                 `json:"ssdeep,omitempty"`
	CRC32       string                 `json:"crc32,omitempty"`
	Magic       string                 `json:"magic,omitempty"`
	Size        uint64                 `json:"size,omitempty"`
	Exif        map[string]string      `json:"exif,omitempty"`
	Tags        map[string]interface{} `json:"tags,omitempty"`
	TriD        []string               `json:"trid,omitempty"`
	Packer      []string               `json:"packer,omitempty"`
	Strings     []interface{}          `json:"strings,omitempty"`
	MultiAV     map[string]interface{} `json:"multiav,omitempty"`
	PE          interface{}            `json:"pe,omitempty"`
	Histogram   []int                  `json:"histogram,omitempty"`
	ByteEntropy []int                  `json:"byte_entropy,omitempty"`
	Ml          map[string]interface{} `json:"ml,omitempty"`
	FileType    string                 `json:"filetype,omitempty"`
}

UpdateUserRequest represents a File update request.

type UploadDownloader

type UploadDownloader interface {
	Upload(ctx context.Context, bucket, key string, file io.Reader) error
	Download(ctx context.Context, bucket, key string, file io.Writer) error
}

Jump to

Keyboard shortcuts

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