package
1.46.0
Repository: https://github.com/gofr-dev/gofr.git
Documentation: pkg.go.dev

# README

Using File Bind Example

This GoFr example demonstrates the use of context Bind where incoming request has multipart-form data and then binds it to the fields of the struct. GoFr currently supports zip file type and also binds the more generic multipart.FileHeader

Usage

type Data struct {
	Compressed file.Zip `file:"upload"`

	FileHeader *multipart.FileHeader `file:"file_upload"`
}

func Handler(c *gofr.Context) (any, error) {
	var d Data

	// bind the multipart data into the variable d
	err := c.Bind(&d)
	if err != nil {
		return nil, err
	}
}

To run the example use the command below:

go run main.go