mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-01-07 12:17:02 +08:00
feat: minio video snapshot
This commit is contained in:
parent
cb929e4c9c
commit
a643c2f89e
@ -126,13 +126,14 @@ api:
|
|||||||
# Configuration for Aliyun OSS
|
# Configuration for Aliyun OSS
|
||||||
object:
|
object:
|
||||||
enable: "minio"
|
enable: "minio"
|
||||||
apiURL: http://127.0.0.1:10002/object/
|
apiURL: http://127.0.0.1:10002
|
||||||
minio:
|
minio:
|
||||||
bucket: "openim"
|
bucket: "openim"
|
||||||
endpoint: http://127.0.0.1:10005
|
endpoint: http://127.0.0.1:10005
|
||||||
accessKeyID: root
|
accessKeyID: root
|
||||||
secretAccessKey: openIM123
|
secretAccessKey: openIM123
|
||||||
sessionToken: ""
|
sessionToken: ""
|
||||||
|
thumbnailApi: "http://127.0.0.1:10003"
|
||||||
cos:
|
cos:
|
||||||
bucketURL: "https://temp-1252357374.cos.ap-chengdu.myqcloud.com"
|
bucketURL: "https://temp-1252357374.cos.ap-chengdu.myqcloud.com"
|
||||||
secretID: ""
|
secretID: ""
|
||||||
|
|||||||
@ -48,6 +48,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
if apiURL[len(apiURL)-1] != '/' {
|
if apiURL[len(apiURL)-1] != '/' {
|
||||||
apiURL += "/"
|
apiURL += "/"
|
||||||
}
|
}
|
||||||
|
apiURL += "object/"
|
||||||
rdb, err := cache.NewRedis()
|
rdb, err := cache.NewRedis()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@ -119,6 +119,7 @@ type configStruct struct {
|
|||||||
AccessKeyID string `yaml:"accessKeyID"`
|
AccessKeyID string `yaml:"accessKeyID"`
|
||||||
SecretAccessKey string `yaml:"secretAccessKey"`
|
SecretAccessKey string `yaml:"secretAccessKey"`
|
||||||
SessionToken string `yaml:"sessionToken"`
|
SessionToken string `yaml:"sessionToken"`
|
||||||
|
ThumbnailApi string `yaml:"thumbnailApi"`
|
||||||
} `yaml:"minio"`
|
} `yaml:"minio"`
|
||||||
Cos struct {
|
Cos struct {
|
||||||
BucketURL string `yaml:"bucketURL"`
|
BucketURL string `yaml:"bucketURL"`
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"github.com/minio/minio-go/v7"
|
"github.com/minio/minio-go/v7"
|
||||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||||
"github.com/minio/minio-go/v7/pkg/signer"
|
"github.com/minio/minio-go/v7/pkg/signer"
|
||||||
@ -56,9 +57,17 @@ func NewMinio() (s3.Interface, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
imageApi := conf.ThumbnailApi
|
||||||
|
if imageApi != "" {
|
||||||
|
if imageApi[len(imageApi)-1] != '/' {
|
||||||
|
imageApi += "/"
|
||||||
|
}
|
||||||
|
imageApi += "image?"
|
||||||
|
}
|
||||||
m := &Minio{
|
m := &Minio{
|
||||||
bucket: conf.Bucket,
|
bucket: conf.Bucket,
|
||||||
bucketURL: conf.Endpoint + "/" + conf.Bucket + "/",
|
bucketURL: conf.Endpoint + "/" + conf.Bucket + "/",
|
||||||
|
imageApi: imageApi,
|
||||||
opts: opts,
|
opts: opts,
|
||||||
core: &minio.Core{Client: client},
|
core: &minio.Core{Client: client},
|
||||||
lock: &sync.Mutex{},
|
lock: &sync.Mutex{},
|
||||||
@ -75,6 +84,7 @@ func NewMinio() (s3.Interface, error) {
|
|||||||
type Minio struct {
|
type Minio struct {
|
||||||
bucket string
|
bucket string
|
||||||
bucketURL string
|
bucketURL string
|
||||||
|
imageApi string
|
||||||
opts *minio.Options
|
opts *minio.Options
|
||||||
core *minio.Core
|
core *minio.Core
|
||||||
lock sync.Locker
|
lock sync.Locker
|
||||||
@ -324,5 +334,20 @@ func (m *Minio) AccessURL(ctx context.Context, name string, expire time.Duration
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return u.String(), nil
|
if opt.Image == nil && opt.Video == nil {
|
||||||
|
return u.String(), nil
|
||||||
|
}
|
||||||
|
if m.imageApi == "" {
|
||||||
|
return "", errs.ErrInternalServer.Wrap("minio: thumbnail not configured")
|
||||||
|
}
|
||||||
|
query := make(url.Values)
|
||||||
|
query.Set("url", u.String())
|
||||||
|
if opt.Image != nil {
|
||||||
|
query.Set("type", "image")
|
||||||
|
}
|
||||||
|
if opt.Video != nil {
|
||||||
|
query.Set("type", "video")
|
||||||
|
query.Set("time", strconv.Itoa(int(opt.Video.Time/time.Millisecond)))
|
||||||
|
}
|
||||||
|
return m.imageApi + query.Encode(), nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user