using-file-bind

command
v1.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

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) (interface{}, 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

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL