Documentation
¶
Index ¶
- Constants
- Variables
- func Dirname(name string) string
- func ErrNotExist(err error) error
- func FindIndex(arr []string, value string) int
- func GetIP(r *http.Request) string
- func GetPathname(folder, name string, share Share) string
- func IsNotExist(err error) bool
- func RemoveIndex(arr []string, index int) []string
- func SafeWrite(w io.Writer, content string)
- func SanitizeName(name string, removeSlash bool) (string, error)
- func SaveJSON(storageApp Storage, filename string, content interface{}) error
- func SendLargeFile(ctx context.Context, storageApp Storage, item StorageItem, req request.Request) (*http.Response, error)
- func SetPrefsCookie(w http.ResponseWriter, request Request)
- func URL(folder, name string, share Share) string
- type Aggregate
- type Auth
- type ByHybridSort
- type Crud
- type Event
- type EventBus
- type EventConsumer
- type EventProducer
- type EventType
- type ExifResponse
- type Preferences
- type RenderItem
- type Request
- type Share
- type ShareManager
- type Storage
- type StorageItem
- type Webhook
- type WebhookManager
Constants ¶
const (
// MetadataDirectoryName directory where metadata are stored
MetadataDirectoryName = ".fibr"
)
Variables ¶
var ( // ArchiveExtensions contains extensions of Archive ArchiveExtensions = map[string]bool{".zip": true, ".tar": true, ".gz": true, ".rar": true} // AudioExtensions contains extensions of Audio AudioExtensions = map[string]bool{".mp3": true} // CodeExtensions contains extensions of Code CodeExtensions = map[string]bool{".html": true, ".css": true, ".js": true, ".jsx": true, ".json": true, ".yml": true, ".yaml": true, ".toml": true, ".md": true, ".go": true, ".py": true, ".java": true, ".xml": true} // ExcelExtensions contains extensions of Excel ExcelExtensions = map[string]bool{".xls": true, ".xlsx": true, ".xlsm": true} // ImageExtensions contains extensions of Image ImageExtensions = map[string]bool{".jpg": true, ".jpeg": true, ".png": true, ".gif": true, ".svg": true, ".tiff": true} // PdfExtensions contains extensions of Pdf PdfExtensions = map[string]bool{".pdf": true} // VideoExtensions contains extensions of Video VideoExtensions = map[string]string{".mp4": "video/mp4", ".mov": "video/quicktime", ".avi": "video/x-msvideo"} // StreamExtensions contains extensions of streamable content StreamExtensions = map[string]bool{".ts": true} // WordExtensions contains extensions of Word WordExtensions = map[string]bool{".doc": true, ".docx": true, ".docm": true} )
var ( NoneShare = Share{} // DefaultDisplay format DefaultDisplay = "grid" )
var ( // BufferPool for io.CopyBuffer BufferPool = sync.Pool{ New: func() interface{} { return bytes.NewBuffer(make([]byte, 4*1024)) }, } // SlowClient allows 2 minutes timeout SlowClient = request.CreateClient(2*time.Minute, request.NoRedirection) )
Functions ¶
func GetPathname ¶
GetPathname computes pathname for given params
func RemoveIndex ¶
RemoveIndex removes element at given index, if valid
func SanitizeName ¶
SanitizeName return sanitized name (remove diacritics)
func SendLargeFile ¶ added in v0.9.0
func SendLargeFile(ctx context.Context, storageApp Storage, item StorageItem, req request.Request) (*http.Response, error)
SendLargeFile in a request with buffered copy
func SetPrefsCookie ¶ added in v0.4.1
func SetPrefsCookie(w http.ResponseWriter, request Request)
SetPrefsCookie set preferences cookie for given request
Types ¶
type Aggregate ¶ added in v0.7.0
type Aggregate struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
Location string `json:"location"`
}
Aggregate contains aggregated data for a folder
type Auth ¶ added in v0.8.0
type Auth interface {
IsAuthenticated(*http.Request) (ident.Provider, model.User, error)
IsAuthorized(context.Context, string) bool
}
Auth manager user authentication/authorization
type ByHybridSort ¶ added in v0.9.0
type ByHybridSort []StorageItem
ByHybridSort implements Sorter by type, name then modification time
func (ByHybridSort) Len ¶ added in v0.9.0
func (a ByHybridSort) Len() int
func (ByHybridSort) Less ¶ added in v0.9.0
func (a ByHybridSort) Less(i, j int) bool
func (ByHybridSort) Swap ¶ added in v0.9.0
func (a ByHybridSort) Swap(i, j int)
type Crud ¶ added in v0.8.0
type Crud interface {
Start(done <-chan struct{})
Browser(http.ResponseWriter, Request, StorageItem, renderer.Message) (string, int, map[string]interface{}, error)
List(http.ResponseWriter, Request, renderer.Message) (string, int, map[string]interface{}, error)
Get(http.ResponseWriter, *http.Request, Request) (string, int, map[string]interface{}, error)
Post(http.ResponseWriter, *http.Request, Request)
Create(http.ResponseWriter, *http.Request, Request)
Upload(http.ResponseWriter, *http.Request, Request, map[string]string, *multipart.Part)
Rename(http.ResponseWriter, *http.Request, Request)
Delete(http.ResponseWriter, *http.Request, Request)
}
Crud for user to interfact with filesystem
type Event ¶ added in v0.7.0
type Event struct {
New *StorageItem `json:"new,omitempty"`
Metadata map[string]string `json:"metadata"`
Item StorageItem `json:"item"`
Type EventType `json:"type"`
}
Event describes an event on fibr
func NewAccessEvent ¶ added in v0.8.0
func NewAccessEvent(item StorageItem, r *http.Request) Event
NewAccessEvent creates a new access event
func NewDeleteEvent ¶ added in v0.7.0
func NewDeleteEvent(item StorageItem) Event
NewDeleteEvent creates a new delete event
func NewRenameEvent ¶ added in v0.7.0
func NewRenameEvent(old, new StorageItem) Event
NewRenameEvent creates a new rename event
func NewStartEvent ¶ added in v0.7.0
func NewStartEvent(item StorageItem) Event
NewStartEvent creates a new start event
func NewUploadEvent ¶ added in v0.7.0
func NewUploadEvent(item StorageItem) Event
NewUploadEvent creates a new upload event
type EventBus ¶ added in v0.7.0
type EventBus struct {
// contains filtered or unexported fields
}
EventBus describes a channel for exchanging Event
func NewEventBus ¶ added in v0.7.0
func NewEventBus(size uint, prometheusRegisterer prometheus.Registerer) (EventBus, error)
NewEventBus create an event exchange channel
func (EventBus) Start ¶ added in v0.7.0
func (e EventBus) Start(done <-chan struct{}, consumers ...EventConsumer)
Start the distibution of Event
type EventConsumer ¶ added in v0.7.0
type EventConsumer func(Event)
EventConsumer is a func that consume an event
type EventProducer ¶ added in v0.7.0
EventProducer is a func that push an event
type EventType ¶ added in v0.7.0
type EventType uint
EventType is the enumeration of event that can happen
const ( // UploadEvent occurs when someone upload a file UploadEvent EventType = iota // CreateDir occurs when a directory is created CreateDir // RenameEvent occurs when an item is renamed RenameEvent // DeleteEvent occurs when an item is deleted DeleteEvent // StartEvent occurs when fibr start StartEvent // AccessEvent occurs when content is accessed AccessEvent )
func ParseEventType ¶ added in v0.8.0
ParseEventType parse raw string into an EventType
func (EventType) MarshalJSON ¶ added in v0.8.0
MarshalJSON marshals the enum as a quoted json string
func (*EventType) UnmarshalJSON ¶ added in v0.8.0
UnmarshalJSON unmarshal JSON
type ExifResponse ¶ added in v0.10.0
type ExifResponse struct {
Exif model.Exif `json:"exif"`
Item StorageItem `json:"item"`
}
ExifResponse from AMQP
type Preferences ¶
type Preferences struct {
ListLayoutPath []string
}
Preferences holds preferences of the user
type RenderItem ¶
type RenderItem struct {
Aggregate
ID string
URI string
StorageItem
}
RenderItem is a storage item with an id
type Request ¶
type Request struct {
Path string
Display string
Preferences Preferences
CanEdit bool
CanWebhook bool
}
Request from user
func (Request) Description ¶ added in v0.4.1
Description returns description of the page
func (Request) GetFilepath ¶
GetFilepath of request
func (Request) LayoutPath ¶
LayoutPath returns layout of given path based on preferences
type Share ¶
type Share struct {
}
Share stores informations about shared paths
func (Share) CheckPassword ¶
CheckPassword verifies that request has correct password for share
type Storage ¶
type Storage interface {
WithIgnoreFn(ignoreFn func(StorageItem) bool) Storage
Info(pathname string) (StorageItem, error)
List(pathname string) ([]StorageItem, error)
WriterTo(pathname string) (io.WriteCloser, error)
ReaderFrom(pathname string) (io.ReadSeekCloser, error)
Walk(pathname string, walkFn func(StorageItem, error) error) error
CreateDir(pathname string) error
Rename(oldName, newName string) error
Remove(pathname string) error
UpdateDate(pathname string, date time.Time) error
}
Storage describe action on a storage provider
type StorageItem ¶
type StorageItem struct {
Date time.Time `json:"date"`
Name string `json:"name"`
Pathname string `json:"pathname"`
IsDir bool `json:"isDir"`
Size int64 `json:"size"`
}
StorageItem describe item on a storage provider
func (StorageItem) Dir ¶ added in v0.8.0
func (s StorageItem) Dir() string
Dir return the nearest directory (self of parent)
func (StorageItem) Extension ¶
func (s StorageItem) Extension() string
Extension gives extensions of item
func (StorageItem) IsImage ¶
func (s StorageItem) IsImage() bool
IsImage determine if item if an image
func (StorageItem) IsVideo ¶
func (s StorageItem) IsVideo() bool
IsVideo determine if item if a video