mirror of
https://github.com/derfenix/webarchive.git
synced 2026-03-11 21:35:34 +03:00
Initial commit
This commit is contained in:
30
entity/file.go
Normal file
30
entity/file.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gabriel-vasile/mimetype"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func NewFile(name string, data []byte) File {
|
||||
detected := mimetype.Detect(data)
|
||||
|
||||
return File{
|
||||
ID: uuid.New(),
|
||||
Name: name,
|
||||
MimeType: detected.String(),
|
||||
Size: int64(len(data)),
|
||||
Data: data,
|
||||
Created: time.Now(),
|
||||
}
|
||||
}
|
||||
|
||||
type File struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
MimeType string
|
||||
Size int64
|
||||
Data []byte
|
||||
Created time.Time
|
||||
}
|
||||
Reference in New Issue
Block a user