mirror of
https://github.com/vbatts/imgsrv.git
synced 2025-06-30 14:38:28 +00:00
moved types out to a package
This commit is contained in:
parent
d80427788d
commit
967daf48b2
4 changed files with 21 additions and 18 deletions
33
types/types.go
Normal file
33
types/types.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"mime"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Info struct {
|
||||
Keywords []string // tags
|
||||
Ip string // who uploaded it
|
||||
Random int64
|
||||
TimeStamp time.Time "timestamp,omitempty"
|
||||
}
|
||||
|
||||
type File struct {
|
||||
Metadata Info ",omitempty"
|
||||
Md5 string
|
||||
ChunkSize int
|
||||
UploadDate time.Time
|
||||
Length int64
|
||||
Filename string ",omitempty"
|
||||
IsImage bool
|
||||
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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue