file

package
v0.0.0-...-29f5810 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileKind int = iota
	ImageKind
)

Variables

This section is empty.

Functions

func GetImagesForContent

func GetImagesForContent(db *mgo.Database, c *cms.Content) (err error)

GetImagesForContent fetches images for the provided content which are located in the Content.Images attribute only.

func RemoveFile

func RemoveFile(col *mgo.Collection, idStr string, filesDir string) error

RemoveFile deletes a file from a file system and a database.

func UploadFromForm

func UploadFromForm(col *mgo.Collection, fh *multipart.FileHeader, outputDir, caption, credits string, optimize bool) error

UploadFromForm dumps a file to a file system and upserts into a mongo database.

Types

type File

type File struct {
	ID    bson.ObjectId `bson:"_id"`
	Title string
	// Credits field contains information about a file source or a name of an author.
	Credits string
	Kind    int
	URL     string
	Size    int64
	Created time.Time

	// Optimized can contain several URLs to optimized versions of a file from
	// the original File.URL field. Usually, it is used for images to store several
	// formats and sizes of them.
	Optimized []*OptimizedImage
}

File is used for file uploads.

func AllFiles

func AllFiles(col *mgo.Collection, query interface{}) ([]*File, error)

AllFiles returns files from a database.

func AllFilesByPage

func AllFilesByPage(col *mgo.Collection, query interface{}, perpage, page int) (items []*File, prev, next, total int, err error)

AllFilesByPage returns files by page.

type OptimizedImage

type OptimizedImage struct {
	URL  string
	Size int64
}

Jump to

Keyboard shortcuts

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