storage

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StorageHandler

type StorageHandler interface {
	// Accepts the file and stores it. Does NOT insert the file into the db.
	AcceptFile(*multipart.FileHeader, multipart.File) (*iface.File, error)

	// Remove the file from storage
	DeleteFile(hash string) error

	// Grabs the file data from storage by hash (reads the whole file!! can be memory-intensive!!)
	GetFile(hash string) ([]byte, error)

	// send file to http.ResponseWriter (use this instead of GetFile() to send files to http responses!)
	SendFile(ifile *iface.File, w http.ResponseWriter) error
}

func NewStorageIO

func NewStorageIO(root string) StorageHandler

TODO: add an error result ? maybe ?

type StorageIOHandler

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

func (*StorageIOHandler) AcceptFile

func (storage *StorageIOHandler) AcceptFile(header *multipart.FileHeader, file multipart.File) (*iface.File, error)

Accepts the file and stores it. Does NOT insert the file into the db.

func (*StorageIOHandler) DeleteFile

func (storage *StorageIOHandler) DeleteFile(hash string) error

Remove the file from storage

func (*StorageIOHandler) GetFile

func (storage *StorageIOHandler) GetFile(hash string) ([]byte, error)

reads whole file into memory from storage

func (*StorageIOHandler) SendFile

func (storage *StorageIOHandler) SendFile(ifile *iface.File, w http.ResponseWriter) error

Jump to

Keyboard shortcuts

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