Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package service
import (
"bytes"
"context"
"time"
"go-common/library/ecode"
"go-common/library/log"
)
// Upload upload.
func (s *Service) Upload(c context.Context, fileName, fileType string, t time.Time, body []byte) (location string, err error) {
if len(body) == 0 {
err = ecode.FeedbackBodyNotExist
return
}
if len(body) > s.c.Bfs.MaxFileSize {
err = ecode.FeedbackBodyTooLarge
return
}
if location, err = s.dao.Upload(c, fileName, fileType, t.Unix(), bytes.NewReader(body)); err != nil {
log.Error("s.dao.Upload error(%v)", err)
return
}
return
}