razbox

package module
v0.0.0-...-732bfc7 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MIT Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MaxThumbnailWidth = internal.MaxThumbnailWidth

MaxThumbnailWidth ...

Variables

This section is empty.

Functions

func ExtendType

func ExtendType(mime, filename string) (symbol template.HTML, primaryType, secondaryType, extension string)

ExtendType ...

func SortFolderEntries

func SortFolderEntries(entries []*FolderEntry)

SortFolderEntries sorts the entries by the upload date (most recent first)

Types

type API

type API struct {
	CacheDuration       time.Duration
	CookieExpiration    time.Duration
	ThumbnailRetryAfter time.Duration
	AuthsPerMin         int
	// contains filtered or unexported fields
}

API ...

func NewAPI

func NewAPI(root string) (*API, error)

NewAPI ...

func (*API) Auth

func (api *API) Auth(pr *beepboop.PageRequest, folderName, accessType, password string) error

Auth ...

func (*API) ChangeFolderPassword

func (api *API) ChangeFolderPassword(sess *beepboop.Session, folderName, accessType, password string) error

ChangeFolderPassword ...

func (*API) ConnectDB

func (api *API) ConnectDB(redisUrl string) (*beepboop.DB, error)

ConnectDB ...

func (*API) CreateSubfolder

func (api *API) CreateSubfolder(sess *beepboop.Session, folderName, subfolder string) (string, error)

CreateSubfolder ...

func (*API) DeleteFile

func (api *API) DeleteFile(sess *beepboop.Session, filePath string) error

DeleteFile ...

func (*API) DeleteSubfolder

func (api *API) DeleteSubfolder(sess *beepboop.Session, folderName, subfolder string) error

DeleteSubfolder ...

func (*API) DownloadFileToFolder

func (api *API) DownloadFileToFolder(sess *beepboop.Session, o *DownloadFileToFolderOptions) error

DownloadFileToFolder ...

func (*API) EditFile

func (api *API) EditFile(sess *beepboop.Session, o *EditFileOptions) error

EditFile ...

func (*API) GetArchiveWalker

func (api *API) GetArchiveWalker(sess *beepboop.Session, filePath string) (ArchiveWalker, error)

GetArchiveWalker ...

func (*API) GetFileThumbnail

func (api *API) GetFileThumbnail(sess *beepboop.Session, filePath string) (*Thumbnail, error)

GetFileThumbnail ...

func (*API) GetFolderEntries

func (api *API) GetFolderEntries(sess *beepboop.Session, folderOrFilename string) ([]*FolderEntry, *FolderFlags, error)

GetFolderEntries ...

func (*API) GetFolderFlags

func (api *API) GetFolderFlags(sess *beepboop.Session, folderName string) (*FolderFlags, error)

GetFolderFlags ...

func (*API) GetInternalFilename

func (api *API) GetInternalFilename(sess *beepboop.Session, filePath string) (string, error)

GetInternalFilename ...

func (*API) GetSubfolders

func (api *API) GetSubfolders(sess *beepboop.Session, folderName string) ([]string, error)

GetSubfolders ...

func (*API) OpenFile

func (api *API) OpenFile(sess *beepboop.Session, filePath string) (FileReader, error)

OpenFile ...

func (*API) UploadFile

func (api *API) UploadFile(sess *beepboop.Session, o *UploadFileOptions) error

UploadFile ...

type ArchiveFile

type ArchiveFile interface {
	io.Reader
	Name() string
	Size() int64
	ModTime() time.Time
}

ArchiveFile ...

type ArchiveWalker

type ArchiveWalker interface {
	Walk(func(ArchiveFile) error) error
}

ArchiveWalker ...

type DownloadFileToFolderOptions

type DownloadFileToFolderOptions struct {
	Folder    string
	URL       string
	Filename  string
	Tags      []string
	Overwrite bool
	Public    bool
}

DownloadFileToFolderOptions ...

type EditFileOptions

type EditFileOptions struct {
	Folder           string
	OriginalFilename string
	NewFilename      string
	Tags             []string
	Public           bool
	MoveTo           string
}

EditFileOptions ...

type ErrBadHTTPResponseStatus

type ErrBadHTTPResponseStatus struct {
	StatusCode int
}

ErrBadHTTPResponseStatus ...

func (ErrBadHTTPResponseStatus) Error

func (err ErrBadHTTPResponseStatus) Error() string

type ErrFolderBusy

type ErrFolderBusy struct{}

ErrFolderBusy ...

func (ErrFolderBusy) Error

func (err ErrFolderBusy) Error() string

type ErrInvalidMoveLocation

type ErrInvalidMoveLocation struct {
	Location string
}

ErrInvalidMoveLocation ...

func (ErrInvalidMoveLocation) Error

func (err ErrInvalidMoveLocation) Error() string

type ErrInvalidName

type ErrInvalidName struct {
	Name string
}

ErrInvalidName ...

func (ErrInvalidName) Error

func (err ErrInvalidName) Error() string

type ErrNoFiles

type ErrNoFiles struct{}

ErrNoFiles ...

func (ErrNoFiles) Error

func (err ErrNoFiles) Error() string

type ErrNoReadAccess

type ErrNoReadAccess struct {
	Folder string
}

ErrNoReadAccess ...

func (ErrNoReadAccess) Error

func (err ErrNoReadAccess) Error() string

type ErrNoWriteAccess

type ErrNoWriteAccess struct {
	Folder string
}

ErrNoWriteAccess ...

func (ErrNoWriteAccess) Error

func (err ErrNoWriteAccess) Error() string

type ErrNotDeletable

type ErrNotDeletable struct {
	Name string
}

ErrNotDeletable ...

func (ErrNotDeletable) Error

func (err ErrNotDeletable) Error() string

type ErrNotFound

type ErrNotFound struct{}

ErrNotFound ...

func (ErrNotFound) Error

func (err ErrNotFound) Error() string

type ErrRateLimitExceeded

type ErrRateLimitExceeded struct {
	ReqPerMin int
}

ErrRateLimitExceeded ...

func (ErrRateLimitExceeded) Error

func (err ErrRateLimitExceeded) Error() string

type ErrSizeLimitExceeded

type ErrSizeLimitExceeded struct{}

ErrSizeLimitExceeded ...

func (ErrSizeLimitExceeded) Error

func (err ErrSizeLimitExceeded) Error() string

type ErrSubfoldersDisabled

type ErrSubfoldersDisabled struct {
	Folder string
}

ErrSubfoldersDisabled ...

func (ErrSubfoldersDisabled) Error

func (err ErrSubfoldersDisabled) Error() string

type ErrUnsupportedFileFormat

type ErrUnsupportedFileFormat struct {
	MIME string
}

ErrUnsupportedFileFormat ...

func (ErrUnsupportedFileFormat) Error

func (err ErrUnsupportedFileFormat) Error() string

type ErrWrongPassword

type ErrWrongPassword struct{}

ErrWrongPassword ...

func (ErrWrongPassword) Error

func (err ErrWrongPassword) Error() string

type FileReader

type FileReader interface {
	http.File
	os.FileInfo
	MimeType() string
}

FileReader ...

type FolderEntry

type FolderEntry struct {
	Folder        bool             `json:"folder,omitempty"`
	Prefix        template.HTML    `json:"prefix,omitempty"`
	Name          string           `json:"name"`
	RelPath       string           `json:"rel_path"`
	MIME          string           `json:"mime,omitempty"`
	PrimaryType   string           `json:"primary_type,omitempty"`
	SecondaryType string           `json:"secondary_type,omitempty"`
	Extension     string           `json:"extension"`
	Tags          []string         `json:"tags,omitempty"`
	Size          int64            `json:"size,omitempty"`
	Uploaded      int64            `json:"uploaded,omitempty"`
	Public        bool             `json:"public,omitempty"`
	EditMode      bool             `json:"edit_mode,omitempty"`
	HasThumbnail  bool             `json:"has_thumbnail,omitempty"`
	ThumbBounds   *ThumbnailBounds `json:"thumb_bounds,omitempty"`
	Archive       bool             `json:"archive,omitempty"`
}

FolderEntry ...

func (*FolderEntry) HasTag

func (f *FolderEntry) HasTag(tag string) bool

HasTag ...

type FolderFlags

type FolderFlags struct {
	EditMode        bool
	Editable        bool
	Deletable       bool
	Configurable    bool
	Subfolders      bool
	MaxUploadSizeMB int64
}

FolderFlags ...

type LimitedReadCloser

type LimitedReadCloser struct {
	R io.ReadCloser
	N int64
}

LimitedReadCloser ...

func (*LimitedReadCloser) Close

func (l *LimitedReadCloser) Close() error

Close implements io.Closer

func (*LimitedReadCloser) Read

func (l *LimitedReadCloser) Read(p []byte) (n int, err error)

Read implements io.Reader

type LimitedReader

type LimitedReader struct {
	R io.Reader
	N int64
}

LimitedReader is like io.LimitedReader, but returns a non-EOF error if limit is exceeded

func (*LimitedReader) Read

func (l *LimitedReader) Read(p []byte) (n int, err error)

Read implements io.Reader

type Thumbnail

type Thumbnail struct {
	Data   []byte
	MIME   string
	Bounds ThumbnailBounds
}

Thumbnail ...

type ThumbnailBounds

type ThumbnailBounds struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

ThumbnailBounds ...

type UploadFileOptions

type UploadFileOptions struct {
	Folder    string
	Files     []*multipart.FileHeader
	Filename  string
	Tags      []string
	Overwrite bool
	Public    bool
}

UploadFileOptions ...

Directories

Path Synopsis
cmd
razbox command
tools
mkfile command
mkfolder command
web

Jump to

Keyboard shortcuts

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