upload

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RelativePath

func RelativePath(base string, path string) string

RelativePath returns a path relative to the base. If a relative path could not be calculated or it contains ' ../`, returns the original path.

Types

type FileItem

type FileItem struct {
	Path      string
	AlbumName string
}

FileItem represents a local file.

func NewFileItem

func NewFileItem(path string) FileItem

func (FileItem) Name

func (m FileItem) Name() string

Name returns the filename.

func (FileItem) Open

func (m FileItem) Open() (io.ReadSeeker, int64, error)

Open returns a stream. Caller should close it finally.

func (FileItem) Remove

func (m FileItem) Remove() error

func (FileItem) Size

func (m FileItem) Size() int64

func (FileItem) String

func (m FileItem) String() string

type FileTracker

type FileTracker interface {
	CacheAsAlreadyUploaded(filePath string) error
	IsAlreadyUploaded(filePath string) (bool, error)
	RemoveAsAlreadyUploaded(filePath string) error
}

FileTracker represents a service to track already uploaded files.

type Filter

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

Filter is a Filter for file uploading

func NewFilter

func NewFilter(includePatterns []string, excludePatterns []string, allowVideos bool) *Filter

NewFilter returns an initialized Filter struct

func (*Filter) IsAllowed

func (f *Filter) IsAllowed(fp string) bool

IsAllowed returns if an item should be uploaded. That means:

  • item is in the include pattern
  • item is not in the exclude pattern

func (*Filter) IsExcluded

func (f *Filter) IsExcluded(fp string) bool

IsExcluded return if an item should be excluded. It's useful for skipping directories that match with an exclusion.

type UploadFolderJob

type UploadFolderJob struct {
	FileTracker FileTracker

	SourceFolder       string
	CreateAlbum        bool
	CreateAlbumBasedOn string
	Filter             *Filter
}

UploadFolderJob represents a job to upload all photos from the specified folder

func (*UploadFolderJob) ScanFolder

func (job *UploadFolderJob) ScanFolder(logger log.Logger) ([]FileItem, error)

ScanFolder return the list of Items{} to be uploaded. It scans the folder and skip non allowed files (includePatterns & excludePattens).

Jump to

Keyboard shortcuts

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