|
|
|
@ -6,6 +6,7 @@ package web
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"image"
|
|
|
|
|
"io"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
@ -22,7 +23,6 @@ import (
|
|
|
|
|
"github.com/rocboss/paopao-ce/internal/model/web"
|
|
|
|
|
"github.com/rocboss/paopao-ce/internal/servants/base"
|
|
|
|
|
"github.com/rocboss/paopao-ce/internal/servants/chain"
|
|
|
|
|
"github.com/rocboss/paopao-ce/pkg/types"
|
|
|
|
|
"github.com/rocboss/paopao-ce/pkg/utils"
|
|
|
|
|
"github.com/rocboss/paopao-ce/pkg/xerror"
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
@ -145,7 +145,7 @@ func (s *privSrv) UploadAttachment(req *web.UploadAttachmentReq) (*web.UploadAtt
|
|
|
|
|
// NOTE: 注意这里将req.File Wrap到一个io.Reader的实例对象中是为了避免下游接口去主动调Close,req.File本身是实现了
|
|
|
|
|
// io.Closer接口的,有的下游接口会断言传参是否实现了io.Closer接口,如果实现了会主动去调,我们这里因为下文中可能还要继续
|
|
|
|
|
// 使用req.File所以应避免下游Close,否则会出现潜在的bug,比如这里的场景就是传一个超大的图片(>10MB)可能就会触发bug了。
|
|
|
|
|
data := types.PureReader(req.File)
|
|
|
|
|
data := io.NopCloser(req.File)
|
|
|
|
|
objectUrl, err := s.oss.PutObject(ossSavePath, data, req.FileSize, req.ContentType, false)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("oss.putObject err: %s", err)
|
|
|
|
|