share

package
v2.0.0-...-86705bf Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateBody

type CreateBody struct {
	Password string `json:"password"`
	Expires  string `json:"expires"`
	Unit     string `json:"unit"`
}
type Link struct {
	Hash         string `json:"hash" storm:"id,index"`
	Path         string `json:"path" storm:"index"`
	UserID       uint   `json:"userID"`
	Expire       int64  `json:"expire"`
	PasswordHash string `json:"password_hash,omitempty"`
	// Token is a random value that will only be set when PasswordHash is set. It is
	// URL-Safe and is used to download links in password-protected shares via a
	// query arg.
	Token string `json:"token,omitempty"`
}

Link is the information needed to build a shareable link.

type Storage

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

Storage is a storage.

func NewStorage

func NewStorage(back StorageBackend) *Storage

NewStorage creates a share links storage from a backend.

func (*Storage) All

func (s *Storage) All() ([]*Link, error)

All wraps a StorageBackend.All.

func (*Storage) Delete

func (s *Storage) Delete(hash string) error

Delete wraps a StorageBackend.Delete

func (*Storage) FindByUserID

func (s *Storage) FindByUserID(id uint) ([]*Link, error)

FindByUserID wraps a StorageBackend.FindByUserID.

func (*Storage) GetByHash

func (s *Storage) GetByHash(hash string) (*Link, error)

GetByHash wraps a StorageBackend.GetByHash.

func (*Storage) GetPermanent

func (s *Storage) GetPermanent(path string, id uint) (*Link, error)

GetPermanent wraps a StorageBackend.GetPermanent

func (*Storage) Gets

func (s *Storage) Gets(path string, id uint) ([]*Link, error)

Gets wraps a StorageBackend.Gets

func (*Storage) Save

func (s *Storage) Save(l *Link) error

Save wraps a StorageBackend.Save

type StorageBackend

type StorageBackend interface {
	All() ([]*Link, error)
	FindByUserID(id uint) ([]*Link, error)
	GetByHash(hash string) (*Link, error)
	GetPermanent(path string, id uint) (*Link, error)
	Gets(path string, id uint) ([]*Link, error)
	Save(s *Link) error
	Delete(hash string) error
}

StorageBackend is the interface to implement for a share storage.

Jump to

Keyboard shortcuts

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