1
0
Fork 0
mirror of https://github.com/vbatts/imgsrv.git synced 2024-12-26 15:56:31 +00:00
imgsrv/types.go

34 lines
627 B
Go
Raw Normal View History

package main
import (
"mime"
"path/filepath"
"strings"
"time"
"fmt"
)
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"
IsImage bool
2013-03-27 20:30:24 +00:00
ContentType string "contentType,omitempty"
}
func (f *File) SetIsImage() {
m_type := mime.TypeByExtension(filepath.Ext(f.Filename))
f.IsImage = strings.Contains(m_type, "image")
fmt.Println(f.Filename,f.IsImage)
}