2013-05-09 16:13:46 +00:00
|
|
|
package types
|
2013-02-11 19:27:38 +00:00
|
|
|
|
2013-05-09 13:36:21 +00:00
|
|
|
import (
|
|
|
|
"mime"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
)
|
2013-02-11 19:27:38 +00:00
|
|
|
|
|
|
|
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"
|
2013-02-11 19:27:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
2013-02-11 19:27:38 +00:00
|
|
|
}
|
2013-05-09 13:36:21 +00:00
|
|
|
|
2013-05-09 16:36:49 +00:00
|
|
|
func (f *File) SetContentType() {
|
|
|
|
f.ContentType = mime.TypeByExtension(filepath.Ext(f.Filename))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *File) IsImage() bool {
|
2013-06-03 14:55:04 +00:00
|
|
|
f.SetContentType()
|
2013-05-09 16:36:49 +00:00
|
|
|
return strings.HasPrefix(f.ContentType, "image")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *File) IsVideo() bool {
|
2013-06-03 14:55:04 +00:00
|
|
|
f.SetContentType()
|
2013-05-09 16:36:49 +00:00
|
|
|
return strings.HasPrefix(f.ContentType, "video")
|
2013-05-09 13:36:21 +00:00
|
|
|
}
|
2013-06-03 14:55:04 +00:00
|
|
|
|
|
|
|
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 the keyword usage for the tag cloud
|
|
|
|
*/
|
|
|
|
type KeywordCount struct {
|
|
|
|
Id string "_id"
|
|
|
|
Value int
|
|
|
|
}
|
|
|
|
|