mirror of
https://github.com/vbatts/imgsrv.git
synced 2025-10-11 20:38:10 +00:00
Open() Create() and Delete() are there'ish. But get/set metadata is not quite right yet. And it seems that _viewing_ an uploaded object is not working. But all of the index fetching is not there yet. Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
46 lines
900 B
Go
46 lines
900 B
Go
package types
|
|
|
|
import (
|
|
"mime"
|
|
"path/filepath"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
type Info struct {
|
|
Keywords []string // tags
|
|
Ip string // who uploaded it
|
|
TimeStamp time.Time "timestamp,omitempty"
|
|
}
|
|
|
|
type File struct {
|
|
Metadata Info ",omitempty"
|
|
Md5 string
|
|
UploadDate time.Time
|
|
Length uint64
|
|
Filename string ",omitempty"
|
|
}
|
|
|
|
// ContentType guesses the mime-type by the file's extension
|
|
func (f *File) ContentType() string {
|
|
return mime.TypeByExtension(filepath.Ext(f.Filename))
|
|
}
|
|
|
|
func (f *File) IsImage() bool {
|
|
return strings.HasPrefix(f.ContentType(), "image")
|
|
}
|
|
|
|
func (f *File) IsVideo() bool {
|
|
return strings.HasPrefix(f.ContentType(), "video")
|
|
}
|
|
|
|
func (f *File) IsAudio() bool {
|
|
return strings.HasPrefix(f.ContentType(), "audio")
|
|
}
|
|
|
|
// IdCount structure used for collecting values for a tag cloud
|
|
type IdCount struct {
|
|
Id string "_id"
|
|
Value int
|
|
Root string
|
|
}
|