mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge branch 'v3dev' of github.com:OpenIMSDK/Open-IM-Server into v3dev
This commit is contained in:
commit
c42a47b6b9
@ -37,8 +37,8 @@ func checkUploadName(ctx context.Context, name string) error {
|
|||||||
return errs.ErrNoPermission.Wrap("opUserID is empty")
|
return errs.ErrNoPermission.Wrap("opUserID is empty")
|
||||||
}
|
}
|
||||||
if !tokenverify.IsManagerUserID(opUserID) {
|
if !tokenverify.IsManagerUserID(opUserID) {
|
||||||
if !strings.HasPrefix(name, opUserID+"_") {
|
if !strings.HasPrefix(name, opUserID+"/") {
|
||||||
return errs.ErrNoPermission.Wrap(fmt.Sprintf("name must start with `%s_`", opUserID))
|
return errs.ErrNoPermission.Wrap(fmt.Sprintf("name must start with `%s/`", opUserID))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -62,7 +63,9 @@ func (s *s3Database) AccessURL(ctx context.Context, name string, expire time.Dur
|
|||||||
}
|
}
|
||||||
opt := &s3.AccessURLOption{
|
opt := &s3.AccessURLOption{
|
||||||
ContentType: obj.ContentType,
|
ContentType: obj.ContentType,
|
||||||
ContentDisposition: `attachment; filename=` + obj.Name,
|
}
|
||||||
|
if filename := filepath.Base(obj.Name); filename != "" {
|
||||||
|
opt.ContentDisposition = `attachment; filename=` + filename
|
||||||
}
|
}
|
||||||
expireTime := time.Now().Add(expire)
|
expireTime := time.Now().Add(expire)
|
||||||
rawURL, err := s.s3.AccessURL(ctx, obj.Key, expire, opt)
|
rawURL, err := s.s3.AccessURL(ctx, obj.Key, expire, opt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user