golang code, upload image through file
f, err := ctx.FormFile("file")
if err != nil {
return err
}
will this cause OOM? what if the file is huge
I look into the source code of golang, found os.Open() in ctx.FormFile(“file”) function
// Open opens and returns the FileHeader's associated File.
func (fh *FileHeader) Open() (File, error) {
if b := fh.content; b != nil {
r := io.NewSectionReader(bytes.NewReader(b), 0, int64(len(b)))
return sectionReadCloser{r, nil}, nil
}
if fh.tmpshared {
f, err := os.Open(fh.tmpfile)
if err != nil {
return nil, err
}
r := io.NewSectionReader(f, fh.tmpoff, fh.Size)
return sectionReadCloser{r, f}, nil
}
return os.Open(fh.tmpfile)
}
New contributor
user25706698 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.