Documentation
¶
Index ¶
- type StorageHandler
- type StorageIOHandler
- func (storage *StorageIOHandler) AcceptFile(header *multipart.FileHeader, file multipart.File) (*iface.File, error)
- func (storage *StorageIOHandler) DeleteFile(hash string) error
- func (storage *StorageIOHandler) GetFile(hash string) ([]byte, error)
- func (storage *StorageIOHandler) SendFile(ifile *iface.File, w http.ResponseWriter) error
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
Click to show internal directories.
Click to hide internal directories.