How to save a *multipart.FileHeader type to gorm postgres db

Viewed 19

am trying to upload an image using the 'content-type: multipart/form-data; it works but am having troubles saving it to the database using GORM

type Avatar struct{
Image        *multipart.FileHeader `form:"image"`

}

i tried to make the image field to type bytes but it throws an error

unsupported data type: net/textproto.MIMEHeader: Table not set, please set it like: db.Model(&user) or db.Table(\"users\")

my model

type ImageUpload struct {
Image        byte`json:"image"`
}

and how do you convert the *multipart.FileHeader i.e image to BLOB

0 Answers
Related