Rainbond/api/controller/upload/body.go

30 lines
489 B
Go
Raw Normal View History

2018-09-28 13:09:25 +08:00
package upload
2018-09-27 19:24:15 +08:00
import (
"io"
"mime/multipart"
"os"
)
// Upload body info.
type body struct {
XFile *os.File
body io.Reader
MR *multipart.Reader
Available bool
}
// Check exists body in xfile and return body.
2018-09-28 13:09:25 +08:00
func newBody(req_body io.Reader) (*body, error) {
2019-02-12 15:40:42 +08:00
return &body{body: req_body, Available: true}, nil
2018-09-27 19:24:15 +08:00
}
// Close filehandler of body if XFile exists.
func (body *body) Close() error {
if body.XFile != nil {
return body.XFile.Close()
}
return nil
}