package item import ( "fmt" "github.com/ponzu-cms/ponzu/management/editor" ) // FileUpload represents the file uploaded to the system type FileUpload struct { Item Name string `json:"name"` Path string `json:"path"` ContentLength int64 `json:"content_length"` ContentType string `json:"content_type"` } // String partially implements item.Identifiable and overrides Item's String() func (f *FileUpload) String() string { return f.Name } // MarshalEditor writes a buffer of html to edit a Post and partially implements editor.Editable func (f *FileUpload) MarshalEditor() ([]byte, error) { view, err := editor.Form(f, editor.Field{ View: []byte(`

` + f.Name + `

File information:

`), }, ) if err != nil { return nil, err } open := []byte(`
File Uploads
`) close := []byte(`
`) script := []byte(` `) view = append(open, view...) view = append(view, close...) view = append(view, script...) return view, nil } func (f *FileUpload) Push() []string { return []string{ "path", } }