files

package
v0.0.0-...-afa1830 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountSavedFilesByIdentityID

func CountSavedFilesByIdentityID(ctx context.Context, exec boil.ContextExecutor, identityID string) (int, error)

CountSavedFilesByIdentityID ...

func Create

func Create(ctx context.Context, exec boil.ContextExecutor, encryptedFile EncryptedFile) error

Create ...

func CreateSavedFile

func CreateSavedFile(ctx context.Context, exec boil.ContextExecutor, savedFile *SavedFile) error

CreateSavedFile ...

func Delete

func Delete(ctx context.Context, exec boil.ContextExecutor, repo FileStorageRepo, fileID string) error

Delete ...

func DeleteSavedFile

func DeleteSavedFile(ctx context.Context, exec boil.ContextExecutor, id string) error

DeleteSavedFile ...

func Download

func Download(ctx context.Context, repo FileStorageRepo, fileID string) (io.Reader, error)

Download ...

func Upload

func Upload(ctx context.Context, repo FileStorageRepo, fileID string, encData io.Reader) error

Upload ...

Types

type EncryptedFile

type EncryptedFile struct {
	ID   string
	Size int64
}

EncryptedFile ...

func Get

func Get(ctx context.Context, exec boil.ContextExecutor, fileID string) (*EncryptedFile, error)

Get ...

type FileAmazonS3

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

FileAmazonS3 ...

func NewFileAmazonS3

func NewFileAmazonS3(region, bucket string) *FileAmazonS3

NewFileAmazonS3 init an S3 session

func (*FileAmazonS3) Delete

func (s *FileAmazonS3) Delete(ctx context.Context, fileID string) error

Delete data from s3 at {bucket}/{fileID}

func (*FileAmazonS3) Download

func (s *FileAmazonS3) Download(ctx context.Context, fileID string) (io.Reader, error)

Download data from amazon S3 at {bucket}/{fileID}

func (*FileAmazonS3) Upload

func (s *FileAmazonS3) Upload(ctx context.Context, fileID string, data io.Reader) error

Upload data to amazon s3 at {bucket}/{fileID}

type FileStorageRepo

type FileStorageRepo interface {
	Upload(context.Context, string, io.Reader) error
	Download(context.Context, string) (io.Reader, error)
	Delete(context.Context, string) error
}

FileStorageRepo ...

type FileSystem

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

FileSystem contains the files storage location

func NewFileSystem

func NewFileSystem(location string) *FileSystem

NewFileSystem constructor /!\ NOT SAFE TO USE IN PRODUCTION

func (*FileSystem) Delete

func (fs *FileSystem) Delete(ctx context.Context, fileID string) error

Delete a file from the file system

func (*FileSystem) Download

func (fs *FileSystem) Download(ctx context.Context, fileID string) (io.Reader, error)

Download a file from local storage and return its raw data

func (*FileSystem) Upload

func (fs *FileSystem) Upload(ctx context.Context, fileID string, data io.Reader,
) error

Upload an file in file system directory and return its path

type SavedFile

type SavedFile struct {
	ID                string    `json:"id"`
	IdentityID        string    `json:"identity_id"`
	EncryptedFileID   string    `json:"encrypted_file_id"`
	EncryptedMetadata string    `json:"encrypted_metadata"`
	KeyFingerprint    string    `json:"key_fingerprint"`
	CreatedAt         time.Time `json:"created_at"`
}

SavedFile ...

func GetSavedFile

func GetSavedFile(ctx context.Context, exec boil.ContextExecutor, id string) (*SavedFile, error)

GetSavedFile ...

func ListSavedFiles

func ListSavedFiles(ctx context.Context, exec boil.ContextExecutor, filters SavedFileFilters) ([]SavedFile, error)

ListSavedFiles ...

type SavedFileFilters

type SavedFileFilters struct {
	FileID           string
	IdentityID       string
	EncryptedFileIDs []string
	Offset           *int
	Limit            *int
}

SavedFileFilters ...

Jump to

Keyboard shortcuts

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