You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
580 B
25 lines
580 B
package service |
|
|
|
import ( |
|
"bytes" |
|
"context" |
|
"time" |
|
|
|
"go-common/app/admin/main/up/conf" |
|
"go-common/app/admin/main/up/dao" |
|
"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, bfs *conf.Bfs) (location string, err error) { |
|
if len(body) > bfs.MaxFileSize { |
|
err = ecode.FileTooLarge |
|
return |
|
} |
|
if location, err = dao.Upload(c, fileName, fileType, t.Unix(), bytes.NewReader(body), bfs); err != nil { |
|
log.Error("Upload error(%v)", err) |
|
return |
|
} |
|
return |
|
}
|
|
|