files

package
v0.0.0-...-22be18f Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package files represents the file resource

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowedParams

func AllowedParams() []string

AllowedParams returns an array of allowed param keys

func AllowedParamsCreate

func AllowedParamsCreate() []string

AllowedParamsCreate returns only one param which may be added on file upload (sender) Other params are set after create

func Create

func Create(params map[string]string, fh *multipart.FileHeader) (int64, error)

Create inserts a new record in the database using params, and returns the newly created id

func Published

func Published() *query.Query

Published returns a query for all files with status >= published

func Query

func Query() *query.Query

Query returns a new query for files

func Where

func Where(format string, args ...interface{}) *query.Query

Where returns a Where query for files with the arguments supplied

Types

type File

type File struct {
	model.Model
	status.ModelStatus
	Path     string
	Sender   string
	SenderID int64
	UserID   int64
}

File handles saving and retreiving files from the database

func Find

func Find(id int64) (*File, error)

Find returns a single record by id in params

func FindAll

func FindAll(q *query.Query) ([]*File, error)

FindAll returns all results for this query

func New

func New() *File

New creates and initialises a new file instance

func NewWithColumns

func NewWithColumns(cols map[string]interface{}) *File

NewWithColumns creates a new file instance and fills it with data from the database cols provided

func (*File) Destroy

func (m *File) Destroy() error

Destroy removes the record from the database

func (*File) Name

func (m *File) Name() string

Name returns the file path basename

func (*File) NewFilePath

func (m *File) NewFilePath(fh *multipart.FileHeader) error

NewFilePath sets a default path for this file.

func (*File) OwnedBy

func (m *File) OwnedBy(uid int64) bool

OwnedBy returns true if the user id passed in owns this model

func (*File) Update

func (m *File) Update(params map[string]string) error

Update sets the record in the database from params

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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