server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AccessTokenHeaderName = "X-Access-Token"

AccessTokenHeaderName _

View Source
const ErrFileNotFoundCode = "FILE_NOT_FOUND"

ErrFileNotFoundCode _

Variables

View Source
var ErrFileNotFound = errors.New(ErrFileNotFoundCode)

ErrFileNotFound _

View Source
var ErrMissingAccessToken = errors.New("MISSING_ACCESS_TOKEN")

ErrMissingAccessToken _

View Source
var ErrNotAuthorized = errors.New("NOT_AUTHORIZED")

ErrNotAuthorized _

View Source
var ErrUnknown = errors.New("UNKNOWN_ERROR")

ErrUnknown _

Functions

func Router

func Router(cfg *Config) *gin.Engine

Router _

Types

type AuthConfig

type AuthConfig struct {
	AllowedAccessToken string
}

AuthConfig _

type Config

type Config struct {
	S3Host             string
	S3AccessKey        string
	S3AccessSecret     string
	S3Bucket           string
	S3Path             string
	Host               string
	AllowedAccessToken string
}

Config _

type ErrorResponse

type ErrorResponse struct {
	Code        string `json:"code"`
	Message     string `json:"message"`
	Description string `json:"description"`
}

ErrorResponse _

type FileURLBuilder

type FileURLBuilder = func(checksum string) string

FileURLBuilder _

type Filer

type Filer interface {
	Checksum() string
	ContentType() string
	Size() int
	Open() io.Reader
}

Filer _

type MinioInteractor

type MinioInteractor interface {
	PutObject(bucketName string, objectName string, reader io.Reader, objectSize int64, opts minio.PutObjectOptions) (n int64, err error)
	StatObject(bucketName string, objectName string, opts minio.StatObjectOptions) (minio.ObjectInfo, error)
	GetObject(bucketName, objectName string, opts minio.GetObjectOptions) (*minio.Object, error)
}

MinioInteractor _

type MultipartFile

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

MultipartFile _

func NewMultipartFile

func NewMultipartFile(file *multipart.FileHeader) (*MultipartFile, error)

NewMultipartFile _

func (*MultipartFile) Checksum

func (mf *MultipartFile) Checksum() string

Checksum _

func (*MultipartFile) ContentType

func (mf *MultipartFile) ContentType() string

ContentType _

func (*MultipartFile) Open

func (mf *MultipartFile) Open() io.Reader

Open _

func (*MultipartFile) Size

func (mf *MultipartFile) Size() int

Size _

type Storage

type Storage struct {
	S3Bucket   string
	S3Path     string
	URLBuilder FileURLBuilder
	// contains filtered or unexported fields
}

Storage _

func NewStorage

func NewStorage(cfg StorageConfig) (*Storage, error)

NewStorage _

func (*Storage) GetFile

func (u *Storage) GetFile(file Filer) (*StorageFile, error)

GetFile _

func (*Storage) GetFileByChecksum

func (u *Storage) GetFileByChecksum(checksum string) (*StorageFile, error)

GetFileByChecksum _

func (*Storage) UploadFile

func (u *Storage) UploadFile(file Filer, reader io.Reader) error

UploadFile _

func (*Storage) UploadFileIfNotExists

func (u *Storage) UploadFileIfNotExists(file Filer) error

UploadFileIfNotExists _

type StorageConfig

type StorageConfig struct {
	S3Host         string
	S3AccessKey    string
	S3AccessSecret string
	S3Bucket       string
	S3Path         string
	URLBuilder     FileURLBuilder
}

StorageConfig _

type StorageFile

type StorageFile struct {
	URL      string `json:"url"`
	Size     int    `json:"size"`
	Checksum string `json:"checksum"`
	MimeType string `json:"mime_type"`
	// contains filtered or unexported fields
}

StorageFile _

func (*StorageFile) Read

func (sf *StorageFile) Read(p []byte) (n int, err error)

Read _

Jump to

Keyboard shortcuts

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