files

package
v0.0.0-...-17e489a Latest Latest
Warning

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

Go to latest
Published: May 29, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const FileIsLocal = "local"

FileIsLocal denotes whether file is a local file.

View Source
const FileIsRemote = "remote"

FileIsRemote denotes whether file is a remote file.

Variables

View Source
var ProviderConfig map[string]FileProvider

Functions

func SetupProviders

func SetupProviders()

func TranslateProvider

func TranslateProvider(codename string, i *FileProviderInterface)

Types

type BackblazeAuthPayload

type BackblazeAuthPayload struct {
	AccountId   string `json:"accountId"`
	AuthToken   string `json:"authorizationToken"`
	ApiUrl      string `json:"apiUrl"`
	DownloadUrl string `json:"downloadUrl"`
}

type BackblazeBucketInfo

type BackblazeBucketInfo struct {
	BucketId   string `json:"bucketId"`
	BucketName string `json:"bucketName"`
}

type BackblazeBucketInfoPayload

type BackblazeBucketInfoPayload struct {
	Buckets []BackblazeBucketInfo `json:"buckets"`
}

type BackblazeFile

type BackblazeFile struct {
	Action    string `json:"action"`
	Size      int64  `json:"contentLength"`
	Type      string `json:"contentType"`
	FileName  string `json:"fileName"`
	Timestamp int64  `json:"uploadTimestamp"`
}

type BackblazeFilePayload

type BackblazeFilePayload struct {
	Files []BackblazeFile `json:"files"`
}

type BackblazeProvider

type BackblazeProvider struct {
	FileProvider
	Bucket           string
	DownloadLocation string
}

func (*BackblazeProvider) CreateDirectory

func (bp *BackblazeProvider) CreateDirectory(path string) bool

func (*BackblazeProvider) Delete

func (bp *BackblazeProvider) Delete(path string) bool

func (*BackblazeProvider) GetDirectory

func (bp *BackblazeProvider) GetDirectory(path string) Directory

func (*BackblazeProvider) ObjectInfo

func (bp *BackblazeProvider) ObjectInfo(path string) (bool, bool, string)

func (*BackblazeProvider) SaveFile

func (bp *BackblazeProvider) SaveFile(file io.Reader, filename string, path string) bool

func (*BackblazeProvider) SendFile

func (bp *BackblazeProvider) SendFile(path string) (stream io.Reader, contenttype string, err error)

func (*BackblazeProvider) Setup

func (bp *BackblazeProvider) Setup(args map[string]string) bool

Call Backblaze API endpoint to authorize and gather facts.

type BackblazeUploadInfo

type BackblazeUploadInfo struct {
	UploadUrl string `json:"uploadUrl"`
	AuthToken string `json:"authorizationToken"`
}

type Directory

type Directory struct {
	Path  string
	Files []FileInfo
}

Directory contains the path and a collection of FileInfos.

type DiskProvider

type DiskProvider struct {
	FileProvider
}

func (*DiskProvider) CreateDirectory

func (dp *DiskProvider) CreateDirectory(path string) bool

func (*DiskProvider) Delete

func (dp *DiskProvider) Delete(path string) bool

func (*DiskProvider) GetDirectory

func (dp *DiskProvider) GetDirectory(path string) Directory

func (*DiskProvider) ObjectInfo

func (dp *DiskProvider) ObjectInfo(path string) (bool, bool, string)

func (*DiskProvider) SaveFile

func (dp *DiskProvider) SaveFile(file io.Reader, filename string, path string) bool

func (*DiskProvider) SendFile

func (dp *DiskProvider) SendFile(path string) (stream io.Reader, contenttype string, err error)

func (*DiskProvider) Setup

func (dp *DiskProvider) Setup(args map[string]string) bool

type FileInfo

type FileInfo struct {
	IsDirectory bool
	Name        string
	Extension   string
}

FileInfo describes a single file or directory, doing it's best to figure out the extension as well.

type FileProvider

type FileProvider struct {
	Name           string            `yaml:"name"`
	Provider       string            `yaml:"provider"`
	Authentication string            `yaml:"authentication"`
	Location       string            `yaml:"path"`
	Config         map[string]string `yaml:"config"`
}

FileProvider aggregates some very basic properties for authentication and provider decoding.

func (FileProvider) CreateDirectory

func (f FileProvider) CreateDirectory(path string) bool

CreateDirectory will create a directory on services that support it.

func (FileProvider) Delete

func (f FileProvider) Delete(path string) bool

Delete simply deletes a file. This is expected to be a destructive action by default.

func (FileProvider) GetDirectory

func (f FileProvider) GetDirectory(path string) Directory

GetDirectory fetches a directory's contents.

func (FileProvider) ObjectInfo

func (f FileProvider) ObjectInfo(path string) (bool, bool, string)

ObjectInfo will return the info for an object given a path to if the file exists and location. Should return whether the path exists, if the path is a directory, and if it lives on disk. (see constants defined: `FILE_IS_REMOTE` and `FILE_IS_LOCAL`)

func (FileProvider) SaveFile

func (f FileProvider) SaveFile(file io.Reader, filename string, path string) bool

SaveFile will save a file with the contents of the io.Reader at the path specified.

func (FileProvider) SendFile

func (f FileProvider) SendFile(path string) (stream io.Reader, contenttype string, err error)

SendFile returns a filestream, a valid MIME type for the file and an error.

func (FileProvider) Setup

func (f FileProvider) Setup(args map[string]string) bool

Setup runs when the application starts up, and allows for things like authentication.

type FileProviderInterface

type FileProviderInterface interface {
	Setup(args map[string]string) (ok bool)
	GetDirectory(path string) (directory Directory)
	SendFile(path string) (stream io.Reader, contenttype string, err error)
	SaveFile(file io.Reader, filename string, path string) (ok bool)
	ObjectInfo(path string) (exists bool, isDir bool, location string)
	CreateDirectory(path string) (ok bool)
	Delete(path string) (ok bool)
}

FileProviderInterface provides some sane default functions.

type S3Provider

type S3Provider struct {
	FileProvider
	Region    string
	Bucket    string
	Endpoint  string
	KeyID     string
	KeySecret string
	// contains filtered or unexported fields
}

func (*S3Provider) CreateDirectory

func (s *S3Provider) CreateDirectory(path string) bool

CreateDirectory will create a directory on services that support it.

func (*S3Provider) Delete

func (s *S3Provider) Delete(path string) bool

Delete simply deletes a file. This is expected to be a destructive action by default.

func (*S3Provider) GetDirectory

func (s *S3Provider) GetDirectory(path string) Directory

GetDirectory fetches a directory's contents.

func (*S3Provider) ObjectInfo

func (s *S3Provider) ObjectInfo(path string) (bool, bool, string)

func (*S3Provider) SaveFile

func (s *S3Provider) SaveFile(file io.Reader, filename string, path string) bool

func (*S3Provider) SendFile

func (s *S3Provider) SendFile(path string) (stream io.Reader, contenttype string, err error)

func (*S3Provider) Setup

func (s *S3Provider) Setup(args map[string]string) bool

Setup runs when the application starts up, and allows for things like authentication.

Jump to

Keyboard shortcuts

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