iris
iris copied to clipboard
[BUG]Official single file upload problem
Describe the bug Official single file upload problem
To Reproduce Steps to reproduce the behavior:
SaveFormFile source code
// SaveFormFile saves a result of `FormFile` to the "dest" disk full path (directory + filename).
// See `FormFile` and `UploadFormFiles` too.
func (ctx *Context) SaveFormFile(fh *multipart.FileHeader, dest string) (int64, error) {
src, err := fh.Open()
if err != nil {
return 0, err
}
defer src.Close()
out, err := os.Create(dest)
if err != nil {
return 0, err
}
defer out.Close()
return io.Copy(out, src)
}
The official example
// single file
file, fileHeader, err:= ctx.FormFile("file")
if err != nil {
ctx.StopWithError(iris.StatusBadRequest, err)
return
}
// Upload the file to specific destination.
dest := filepath.Join("./uploads", fileHeader.Filename)
ctx.SaveFormFile(file, dest)
The first argument is passed in multipart.fileHeader, but the example uses File
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: mac
iris.Version
- go 1.16
- github.com/kataras/iris/v12 v12.2.0-alpha2.0.20210422110000-6219e5713558
Please make sure the bug is reproducible over the master branch:
$ cd PROJECT
$ go get -u github.com/kataras/iris/v12@master
$ go run .
Additional context Add any other context about the problem here.