1
0
Fork 0
mirror of https://github.com/vbatts/imgsrv.git synced 2024-12-04 22:15:40 +00:00
imgsrv/types/types.go

54 lines
984 B
Go
Raw Normal View History

2013-05-09 16:13:46 +00:00
package types
import (
"mime"
"path/filepath"
"strings"
"time"
)
type Info struct {
2013-03-27 20:30:24 +00:00
Keywords []string // tags
Ip string // who uploaded it
Random int64
TimeStamp time.Time "timestamp,omitempty"
}
type File struct {
2013-03-27 20:30:24 +00:00
Metadata Info ",omitempty"
Md5 string
ChunkSize int
UploadDate time.Time
Length int64
Filename string ",omitempty"
ContentType string "contentType,omitempty"
}
func (f *File) SetContentType() {
f.ContentType = mime.TypeByExtension(filepath.Ext(f.Filename))
}
func (f *File) IsImage() bool {
f.SetContentType()
return strings.HasPrefix(f.ContentType, "image")
}
func (f *File) IsVideo() bool {
f.SetContentType()
return strings.HasPrefix(f.ContentType, "video")
}
func (f *File) IsAudio() bool {
f.SetContentType()
return strings.HasPrefix(f.ContentType, "audio")
}
2013-08-06 00:29:16 +00:00
/*
Structure used for collecting values from mongo for a tag cloud
2013-08-06 00:29:16 +00:00
*/
type IdCount struct {
Id string "_id"
2013-08-06 00:29:16 +00:00
Value int
Root string
2013-08-06 00:29:16 +00:00
}