mirror of
https://github.com/vbatts/imgsrv.git
synced 2024-12-25 23:36:30 +00:00
75ee3c520c
Also, getting the randomize hash name worked out, to avoid file name collisions.
33 lines
627 B
Go
33 lines
627 B
Go
package main
|
|
|
|
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)
|
|
}
|