file

package
v0.0.0-...-dae10ae Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileRepository fileRepository
View Source
var Notfound = fmt.Errorf("file not found")
View Source
var PermissionCheckerFactory permissionCheckerFactory = permissionCheckerFactory{
	// contains filtered or unexported fields
}

Functions

This section is empty.

Types

type File

type File struct {
	ID        int64
	CreatedAt time.Time
	UpdatedAt time.Time

	FileName     string
	FileServerID string
	FilePath     string
	AccessType   FileAccessType // FileAccessType
	RelatedID    int64          // Depend on access type
}

func GetFile

func GetFile(fileID int64) (*File, error)

func GetFileByPreSignID

func GetFileByPreSignID(filePresignedID string) (*File, error)

func UploadFile

func UploadFile(
	accessType FileAccessType,
	relatedID int64,
	file *multipart.FileHeader,
) (File, error)

func (File) CanAccessByUser

func (file File) CanAccessByUser(userID int64) bool

func (File) CreateFilePreSignID

func (file File) CreateFilePreSignID(userID int64, exp int) (string, error)

func (*File) GetFilePath

func (file *File) GetFilePath() string

type FileAccessType

type FileAccessType int8
const (
	FileTypePublic FileAccessType = 10*iota + 1 // set RelatedID to empty
	FileTypeTodo                                // set RelatedID to TodoID
)

type FilePreSignClaims

type FilePreSignClaims struct {
	jwt.StandardClaims

	UserID int64 `json:"uid"`
	FileID int64 `json:"fileID"`
}

type PermissionRequest

type PermissionRequest struct {
	VisitorID int64
	FileID    int64
	RelatedID int64
}

Jump to

Keyboard shortcuts

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