I need to call some methods of fiber context like MultipartForm()
and SaveFile()
inside Gorm's AfterCreate()
hook, how to do that?
CodePudding user response:
You can add a field in the struct to hold fiber.Ctx
in. Then call methods on this in AfterCreate hook.
type User struct {
c *fiber.Ctx
<Other fields>
}
func (user *User) AfterCreate(tx *gorm.DB) (err error) {
// user.c.MultipartForm()/ SaveFile()
return nil
}