files

package
v0.0.0-...-f3ad2b4 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2015 License: MIT Imports: 25 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MEDIA_TYPE_IMAGE = "image"
	MEDIA_TYPE_VIdEO = "video"
)

Variables

This section is empty.

Functions

func GetMimeType

func GetMimeType(path string) string

Types

type File

type File struct {
	Backend kit.FileBackend `db:"-"`

	BackendName string `db:"required;max:100"`
	BackendId   string `db:"required;max:150"`
	Bucket      string `db:"required;max:150"`

	// Used to store the tmp file path before it is persisted to the backend.
	TmpPath string

	Name      string `db:"required;max:1000"`
	Extension string `db:"max:100"`
	FullName  string `db:"required;max:1100"`

	Title       string `db:"max:100"`
	Description string `db:""`

	Size      int64
	Mime      string
	MediaType string

	IsImage bool

	Width  int
	Height int

	// Can be used for sorting.
	Weight int

	// Hash is an MD5 hash of the file contents.
	Hash string `db:"max:50"`

	// Can be used for categorization.
	Type string `db:"max:200"`

	// Stores any additional data required.
	Data map[string]interface{} `db:"marshal"`
}

File that can be extended. You can use FileIntId or FileStrId in almost all cases.

func (*File) Collection

func (f *File) Collection() string

func (*File) GetBackend

func (f *File) GetBackend() kit.FileBackend

func (*File) GetBackendId

func (f *File) GetBackendId() string

func (*File) GetBackendName

func (f *File) GetBackendName() string

func (*File) GetBucket

func (f *File) GetBucket() string

func (*File) GetData

func (f *File) GetData() map[string]interface{}

func (*File) GetDescription

func (f *File) GetDescription() string

func (*File) GetExtension

func (f *File) GetExtension() string

func (*File) GetFullName

func (f *File) GetFullName() string

func (*File) GetHash

func (f *File) GetHash() string

func (*File) GetHeight

func (f *File) GetHeight() int

func (*File) GetIsImage

func (f *File) GetIsImage() bool

func (*File) GetMediaType

func (f *File) GetMediaType() string

func (*File) GetMime

func (f *File) GetMime() string

func (*File) GetName

func (f *File) GetName() string

func (*File) GetSize

func (f *File) GetSize() int64

func (*File) GetTitle

func (f *File) GetTitle() string

func (*File) GetTmpPath

func (f *File) GetTmpPath() string

func (*File) GetType

func (f *File) GetType() string

func (*File) GetWeight

func (f *File) GetWeight() int

func (*File) GetWidth

func (f *File) GetWidth() int

func (*File) SetBackend

func (f *File) SetBackend(x kit.FileBackend)

func (*File) SetBackendId

func (f *File) SetBackendId(x string) error

func (*File) SetBackendName

func (f *File) SetBackendName(x string)

func (*File) SetBucket

func (f *File) SetBucket(x string)

func (*File) SetData

func (f *File) SetData(x map[string]interface{})

func (*File) SetDescription

func (f *File) SetDescription(x string)

func (*File) SetExtension

func (f *File) SetExtension(x string)

func (*File) SetFullName

func (f *File) SetFullName(x string)

func (*File) SetHash

func (f *File) SetHash(x string)

func (*File) SetHeight

func (f *File) SetHeight(x int)

func (*File) SetIsImage

func (f *File) SetIsImage(x bool)

func (*File) SetMediaType

func (f *File) SetMediaType(x string)

func (*File) SetMime

func (f *File) SetMime(x string)

func (*File) SetName

func (f *File) SetName(x string)

func (*File) SetSize

func (f *File) SetSize(x int64)

func (*File) SetTitle

func (f *File) SetTitle(x string)

func (*File) SetTmpPath

func (f *File) SetTmpPath(x string)

func (*File) SetType

func (f *File) SetType(x string)

func (*File) SetWeight

func (f *File) SetWeight(x int)

func (*File) SetWidth

func (f *File) SetWidth(x int)

type FileIntId

type FileIntId struct {
	File
	db.IntIdModel
	users.IntUserModel

	ParentFile   *FileIntId
	ParentFileId uint64

	RelatedFiles []*FileIntId `db:"belongs-to:Id:ParentFileId"`
}

func (*FileIntId) Base64

func (f *FileIntId) Base64() (string, apperror.Error)

Note: needs to be duplicated for FileIntId because access to Id field is required.

func (*FileIntId) GetParentFile

func (f *FileIntId) GetParentFile() kit.File

func (*FileIntId) GetParentFileId

func (f *FileIntId) GetParentFileId() interface{}

func (*FileIntId) GetRelatedFiles

func (f *FileIntId) GetRelatedFiles() []kit.File

func (*FileIntId) Reader

func (f *FileIntId) Reader() (kit.ReadSeekerCloser, apperror.Error)

Note: needs to be duplicated for FileIntId because access to Id field is required.

func (*FileIntId) SetParentFile

func (f *FileIntId) SetParentFile(file kit.File)

func (*FileIntId) SetParentFileId

func (f *FileIntId) SetParentFileId(id interface{})

func (*FileIntId) SetRelatedFiles

func (f *FileIntId) SetRelatedFiles(rawFiles []kit.File)

func (*FileIntId) Writer

func (f *FileIntId) Writer(create bool) (string, io.WriteCloser, apperror.Error)

Note: needs to be duplicated for FileIntId because access to Id field is required.

type FileService

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

func NewFileService

func NewFileService(registry kit.Registry) *FileService

func NewFileServiceWithFs

func NewFileServiceWithFs(registry kit.Registry, dataPath string) *FileService

func (*FileService) AddBackend

func (h *FileService) AddBackend(backend kit.FileBackend)

func (*FileService) Backend

func (h *FileService) Backend(name string) kit.FileBackend

func (FileService) BuildFile

func (h FileService) BuildFile(file kit.File, user kit.User, deleteDir, deleteFile bool) apperror.Error

func (FileService) BuildFileFromPath

func (h FileService) BuildFileFromPath(bucket, path string, deleteFile bool) (kit.File, apperror.Error)

func (*FileService) Create

func (h *FileService) Create(f kit.File, u kit.User) apperror.Error

func (*FileService) Debug

func (s *FileService) Debug() bool

func (*FileService) DefaultBackend

func (h *FileService) DefaultBackend() kit.FileBackend

func (*FileService) Delete

func (h *FileService) Delete(f kit.File, u kit.User) apperror.Error

func (*FileService) DeleteById

func (h *FileService) DeleteById(id interface{}, user kit.User) apperror.Error

func (*FileService) Find

func (h *FileService) Find(q *db.Query) ([]kit.File, apperror.Error)

func (*FileService) FindOne

func (h *FileService) FindOne(id string) (kit.File, apperror.Error)

func (*FileService) Model

func (h *FileService) Model() kit.Model

func (*FileService) New

func (h *FileService) New() kit.File

func (*FileService) Registry

func (s *FileService) Registry() kit.Registry

func (*FileService) Resource

func (h *FileService) Resource() kit.Resource

func (*FileService) SetDebug

func (s *FileService) SetDebug(x bool)

func (*FileService) SetDefaultBackend

func (h *FileService) SetDefaultBackend(name string)

func (*FileService) SetModel

func (h *FileService) SetModel(x kit.Model)

func (*FileService) SetRegistry

func (s *FileService) SetRegistry(x kit.Registry)

func (*FileService) SetResource

func (h *FileService) SetResource(x kit.Resource)

func (*FileService) Update

func (h *FileService) Update(f kit.File, u kit.User) apperror.Error

type FileStrId

type FileStrId struct {
	File
	db.StrIdModel
	users.StrUserModel

	ParentFile   *FileStrId
	ParentFileId string

	RelatedFiles []*FileStrId `db:"belongs-to:Id:ParentFileId"`
}

func (*FileStrId) Base64

func (f *FileStrId) Base64() (string, apperror.Error)

Note: needs to be duplicated for FileStrId because access to Id field is required.

func (*FileStrId) GetParentFile

func (f *FileStrId) GetParentFile() kit.File

func (*FileStrId) GetParentFileId

func (f *FileStrId) GetParentFileId() interface{}

func (*FileStrId) GetRelatedFiles

func (f *FileStrId) GetRelatedFiles() []kit.File

func (*FileStrId) Reader

func (f *FileStrId) Reader() (kit.ReadSeekerCloser, apperror.Error)

Note: needs to be duplicated for FileStrId because access to Id field is required.

func (*FileStrId) SetParentFile

func (f *FileStrId) SetParentFile(file kit.File)

func (*FileStrId) SetParentFileId

func (f *FileStrId) SetParentFileId(id interface{})

func (*FileStrId) SetRelatedFiles

func (f *FileStrId) SetRelatedFiles(rawFiles []kit.File)

func (*FileStrId) Writer

func (f *FileStrId) Writer(create bool) (string, io.WriteCloser, apperror.Error)

Note: needs to be duplicated for FileStrId because access to Id field is required.

type FilesResource

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

func (FilesResource) ApiCreate

func (_ FilesResource) ApiCreate(res kit.Resource, obj kit.Model, r kit.Request) kit.Response

func (FilesResource) HttpRoutes

func (hooks FilesResource) HttpRoutes(res kit.Resource) []kit.HttpRoute

type ImageInfo

type ImageInfo struct {
	Width  int64
	Height int64
	Format string
}

func GetImageInfo

func GetImageInfo(path string) (*ImageInfo, apperror.Error)

Directories

Path Synopsis
backends
fs

Jump to

Keyboard shortcuts

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