store

package
v0.0.0-...-260716b Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a file is not found
	ErrNotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type FileSystemStorageProvider

type FileSystemStorageProvider struct {
	Location         string
	TempFileLocation string
}

FileSystemStorageProvider provides methods to use the local file system as a storage provider.

func (*FileSystemStorageProvider) Delete

func (s *FileSystemStorageProvider) Delete(file rocketchat.File, permanentelyDelete bool) error

func (*FileSystemStorageProvider) Download

func (f *FileSystemStorageProvider) Download(fileCollection string, file rocketchat.File) (string, error)

Download downloads a file from the storage provider and moves it to the temporary file store

func (*FileSystemStorageProvider) SetTempDirectory

func (f *FileSystemStorageProvider) SetTempDirectory(dir string)

SetTempDirectory allows for the setting of the directory that will be used for temporary file store during operations

func (*FileSystemStorageProvider) StoreType

func (f *FileSystemStorageProvider) StoreType() string

StoreType returns the name of the store

func (*FileSystemStorageProvider) Upload

func (f *FileSystemStorageProvider) Upload(path string, filePath string, contentType string) error

Upload uploads a file from given path to the storage provider

type GoogleStorageProvider

type GoogleStorageProvider struct {
	JSONKey          string
	Bucket           string
	TempFileLocation string
}

GoogleStorageProvider provides methods to use the Google Cloud Storage offering as a storage provider.

func (*GoogleStorageProvider) Delete

func (s *GoogleStorageProvider) Delete(file rocketchat.File, permanentelyDelete bool) error

func (*GoogleStorageProvider) Download

func (g *GoogleStorageProvider) Download(fileCollection string, file rocketchat.File) (string, error)

Download downloads a file from the storage provider and moves it to the temporary file store

func (*GoogleStorageProvider) SetTempDirectory

func (g *GoogleStorageProvider) SetTempDirectory(dir string)

SetTempDirectory allows for the setting of the directory that will be used for temporary file store during operations

func (*GoogleStorageProvider) StoreType

func (g *GoogleStorageProvider) StoreType() string

StoreType returns the name of the store

func (*GoogleStorageProvider) Upload

func (g *GoogleStorageProvider) Upload(path string, filePath string, contentType string) error

Upload uploads a file from given path to the storage provider

type GridFSProvider

type GridFSProvider struct {
	Database         string
	Session          mongo.Session
	TempFileLocation string

	Buckets map[string]*gridfs.Bucket
}

GridFSProvider provides methods to use GridFS as a storage provider.

func (*GridFSProvider) Delete

func (s *GridFSProvider) Delete(file rocketchat.File, permanentelyDelete bool) error

func (*GridFSProvider) Download

func (g *GridFSProvider) Download(fileCollection string, file rocketchat.File) (string, error)

Download downloads a file from the storage provider and moves it to the temporary file store

func (*GridFSProvider) SetTempDirectory

func (g *GridFSProvider) SetTempDirectory(dir string)

SetTempDirectory allows for the setting of the directory that will be used for temporary file store during operations

func (*GridFSProvider) StoreType

func (g *GridFSProvider) StoreType() string

StoreType returns the name of the store

func (*GridFSProvider) Upload

func (g *GridFSProvider) Upload(path string, filePath string, contentType string) error

Upload uploads a file from given path to the storage provider (not implemented)

type Provider

type Provider interface {
	// StoreType returns the name of the store
	StoreType() string
	// Upload uploads a file from given path to the storage provider
	Upload(objectPath string, filePath string, contentType string) error
	// Download downloads a file from the storage provider and moves it to the temporary file store
	Download(fileCollection string, file rocketchat.File) (string, error)
	// SetTempDirectory allows for the setting of the directory that will be used for temporary file store during operations
	SetTempDirectory(subdir string)

	Delete(file rocketchat.File, permanentelyDelete bool) error
}

Provider describes the basic contract provided to access a static content storage provider.

type S3Provider

type S3Provider struct {
	Endpoint         string
	Bucket           string
	AccessID         string
	AccessKey        string
	Region           string
	UseSSL           bool
	TempFileLocation string
}

S3Provider provides methods to use any S3 complaint provider as a storage provider.

func (*S3Provider) Delete

func (s *S3Provider) Delete(file rocketchat.File, permanentelyDelete bool) error

Delete permanentely permanentely destroys an object specified by the rocketFile.Amazons3.filepath

func (*S3Provider) Download

func (s *S3Provider) Download(fileCollection string, file rocketchat.File) (string, error)

Download will download the file to temp file store

func (*S3Provider) SetTempDirectory

func (s *S3Provider) SetTempDirectory(dir string)

SetTempDirectory allows for the setting of the directory that will be used for temporary file store during operations

func (*S3Provider) StoreType

func (s *S3Provider) StoreType() string

StoreType returns the name of the store

func (*S3Provider) Upload

func (s *S3Provider) Upload(objectPath string, filePath string, contentType string) error

Upload will upload the file from given file path

Jump to

Keyboard shortcuts

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