mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2026-02-04 10:35:30 +00:00
+Bilder- u. Download-Manager
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package dbmodels
|
||||
|
||||
import "github.com/pocketbase/pocketbase/core"
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
type File struct {
|
||||
core.BaseRecordProxy
|
||||
@@ -14,6 +17,14 @@ func (f *File) SetKey(key string) {
|
||||
f.Set(KEY_FIELD, key)
|
||||
}
|
||||
|
||||
func (f *File) Title() string {
|
||||
return f.GetString(TITLE_FIELD)
|
||||
}
|
||||
|
||||
func (f *File) SetTitle(title string) {
|
||||
f.Set(TITLE_FIELD, title)
|
||||
}
|
||||
|
||||
func (f *File) Description() string {
|
||||
return f.GetString(DESCRIPTION_FIELD)
|
||||
}
|
||||
@@ -29,3 +40,23 @@ func (f *File) FileField() string {
|
||||
func (f *File) SetFileField(file string) {
|
||||
f.Set(FILE_FIELD, file)
|
||||
}
|
||||
|
||||
func (f *File) PublicURL() string {
|
||||
filename := f.FileField()
|
||||
if filename == "" {
|
||||
return ""
|
||||
}
|
||||
return "/api/files/" + FILES_TABLE + "/" + f.Id + "/" + filename
|
||||
}
|
||||
|
||||
func (f *File) Created() types.DateTime {
|
||||
return f.GetDateTime(CREATED_FIELD)
|
||||
}
|
||||
|
||||
func (f *File) CreatedUnix() int64 {
|
||||
t := f.GetDateTime(CREATED_FIELD)
|
||||
if t.IsZero() {
|
||||
return 0
|
||||
}
|
||||
return t.Time().Unix()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user