I'm writing a web server in go.
On one of the pages, the user can upload a file.
I would like to be able to handle zip files.
In the archive/zip
package, I only see two functions which allow me to read from a zip archive :
func OpenReader(name string) (*ReadCloser, error)
func NewReader(r io.ReaderAt, size int64) (*Reader, error)
I would like to avoid writing and reading back from the disk,
if I want to use the second function, I need to know the size of the uploaded file before calling the function.
Question
I will split my question in two parts :
What would be the idiomatic way to read the unzipped content of a zip file uploaded through a standard
multipart/form-data
html form ?-
How can I get the actual size of a file uploaded through a html form ?
func(req *http.Request) { f, h, err := req.FormFile("fileTag") if err != nil { panic(err) } var fileSize int = ?? unzipper, err := zip.NewReader(f, fileSize) }