filestore

package
v0.0.0-...-0b307f8 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package filestore provide a storage backend based on the local file system.

FileStore is a storage backend used as a tusd.DataStore in tusd.NewHandler. It stores the uploads in a directory specified in two different files: The `[id].info` files are used to store the fileinfo in JSON format. The `[id].bin` files contain the raw binary data uploaded. No cleanup is performed so you may want to run a cronjob to ensure your disk is not filled up with old and finished uploads.

In addition, it provides an exclusive upload locking mechansim using lock files which are stored on disk. Each of them stores the PID of the process which aquired the lock. This allows locks to be automatically freed when a process is unable to release it on its own because the process is not alive anymore. For more information, consult the documentation for tusd.LockerDataStore interface, which is implemented by FileStore

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStore

type FileStore struct {
	// Relative or absolute path to store files in. FileStore does not check
	// whether the path exists, use os.MkdirAll in this case on your own.
	Path string
}

See the tusd.DataStore interface for documentation about the different methods.

func New

func New(path string) FileStore

New creates a new file based storage backend. The directory specified will be used as the only storage entry. This method does not check whether the path exists, use os.MkdirAll to ensure. In addition, a locking mechanism is provided.

func (FileStore) ConcatUploads

func (store FileStore) ConcatUploads(dest string, uploads []string) (err error)

func (FileStore) GetInfo

func (store FileStore) GetInfo(id string) (tusd.FileInfo, error)

func (FileStore) GetReader

func (store FileStore) GetReader(id string) (io.Reader, error)

func (FileStore) LockUpload

func (store FileStore) LockUpload(id string) error

func (FileStore) NewUpload

func (store FileStore) NewUpload(info tusd.FileInfo) (id string, err error)

func (FileStore) Terminate

func (store FileStore) Terminate(id string) error

func (FileStore) UnlockUpload

func (store FileStore) UnlockUpload(id string) error

func (FileStore) UseIn

func (store FileStore) UseIn(composer *tusd.StoreComposer)

UseIn sets this store as the core data store in the passed composer and adds all possible extension to it.

func (FileStore) WriteChunk

func (store FileStore) WriteChunk(id string, offset int64, src io.Reader) (int64, error)

Jump to

Keyboard shortcuts

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