shield.go 519 B

1234567891011121314151617181920212223242526
  1. package http
  2. import (
  3. "bytes"
  4. "io"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. func shieldUpload(c *bm.Context) {
  10. file, _, err := c.Request.FormFile("file")
  11. if err != nil {
  12. log.Error("shieldUpload.file.illegal,err::%v", err)
  13. c.JSON(nil, ecode.FileNotExists)
  14. return
  15. }
  16. defer file.Close()
  17. buf := new(bytes.Buffer)
  18. if _, err = io.Copy(buf, file); err != nil {
  19. c.JSON(nil, ecode.RequestErr)
  20. return
  21. }
  22. c.JSON(nil, dmSvc.DmShield(c, buf.Bytes()))
  23. }