mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-31 08:29:33 +08:00 
			
		
		
		
	* fix: to start im or chat, ZooKeeper must be started first. * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: go mod update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: get all userID Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: msggateway add online status call Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * chore: network mode change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add api of get server time Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * feat: remove go work sum Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: pull message add isRead field Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: check msg-transfer script Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: start don't kill old process Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: check component Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: pull message set isRead only message come from single. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: multiple gateway kick user each other. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: add ex field to update group info. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change * cicd: robot automated Change * refactor: change project module name. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: change project module name. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: change project module name. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change * test: for pressure test. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * test: for pressure test. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * test: for pressure test. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * test: message log. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change * fxi: component check output valid info. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fxi: component check output valid info. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * test: send message test log. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change * cicd: robot automated Change * test: remove info log. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * feat: api of send message add sendTime field. Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: add callback for update user's info. * cicd: robot automated Change * fix: change callback command name. * cicd: robot automated Change * fix: single chat unread status change. * fix: single chat unread status change. * fix: single chat unread status change. * fix: user status change. * cicd: robot automated Change * fix: user status change. * fix: user status change. * fix: user status change. * cicd: robot automated Change * fix: ws close when user logout. * fix: remove repeat platform on online status. * cicd: robot automated Change * fix: api send messages for notification conversation . * fix: api send messages for notification conversation . * fix: api send messages for notification conversation . * fix: api send messages for notification conversation . * fix: api send messages for notification conversation . * fix: api send messages for notification conversation. * fix: api send messages for notification conversation. * fix: api send messages for notification conversation. * fix: api send messages for notification conversation. * fix: api send messages for notification conversation. * fix: api send messages for notification conversation. * re: remove router of unsubscribeStatus. * re: remove router of unsubscribeStatus. * re: remove router of unsubscribeStatus. * re: remove router of unsubscribeStatus. * fix: reset branch * fix: not support redis cluster. CROSSSLOT Keys in request don't hash to the same slot * fix: update user.FaceURL do not trigger GroupMemberInfoSetNotification * cicd: robot automated Change * fix: api send messages for notification conversation. * fix: api send messages for notification conversation. --------- Signed-off-by: Gordon <1432970085@qq.com> Signed-off-by: withchao <993506633@qq.com> Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <993506633@qq.com> Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com> Co-authored-by: FGadvancer <FGadvancer@users.noreply.github.com> Co-authored-by: withchao <withchao@users.noreply.github.com>
		
			
				
	
	
		
			329 lines
		
	
	
		
			9.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			329 lines
		
	
	
		
			9.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright © 2023 OpenIM. All rights reserved.
 | |
| //
 | |
| // Licensed under the Apache License, Version 2.0 (the "License");
 | |
| // you may not use this file except in compliance with the License.
 | |
| // You may obtain a copy of the License at
 | |
| //
 | |
| //     http://www.apache.org/licenses/LICENSE-2.0
 | |
| //
 | |
| // Unless required by applicable law or agreed to in writing, software
 | |
| // distributed under the License is distributed on an "AS IS" BASIS,
 | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| // See the License for the specific language governing permissions and
 | |
| // limitations under the License.
 | |
| 
 | |
| package cos
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"errors"
 | |
| 	"fmt"
 | |
| 	"net/http"
 | |
| 	"net/url"
 | |
| 	"strconv"
 | |
| 	"strings"
 | |
| 	"time"
 | |
| 
 | |
| 	"github.com/tencentyun/cos-go-sdk-v5"
 | |
| 
 | |
| 	"github.com/openimsdk/open-im-server/v3/pkg/common/config"
 | |
| 	"github.com/openimsdk/open-im-server/v3/pkg/common/db/s3"
 | |
| )
 | |
| 
 | |
| const (
 | |
| 	minPartSize = 1024 * 1024 * 1        // 1MB
 | |
| 	maxPartSize = 1024 * 1024 * 1024 * 5 // 5GB
 | |
| 	maxNumSize  = 1000
 | |
| )
 | |
| 
 | |
| const (
 | |
| 	imagePng  = "png"
 | |
| 	imageJpg  = "jpg"
 | |
| 	imageJpeg = "jpeg"
 | |
| 	imageGif  = "gif"
 | |
| 	imageWebp = "webp"
 | |
| )
 | |
| 
 | |
| const (
 | |
| 	videoSnapshotImagePng = "png"
 | |
| 	videoSnapshotImageJpg = "jpg"
 | |
| )
 | |
| 
 | |
| func NewCos() (s3.Interface, error) {
 | |
| 	conf := config.Config.Object.Cos
 | |
| 	u, err := url.Parse(conf.BucketURL)
 | |
| 	if err != nil {
 | |
| 		panic(err)
 | |
| 	}
 | |
| 	client := cos.NewClient(&cos.BaseURL{BucketURL: u}, &http.Client{
 | |
| 		Transport: &cos.AuthorizationTransport{
 | |
| 			SecretID:     conf.SecretID,
 | |
| 			SecretKey:    conf.SecretKey,
 | |
| 			SessionToken: conf.SessionToken,
 | |
| 		},
 | |
| 	})
 | |
| 	return &Cos{
 | |
| 		copyURL:    u.Host + "/",
 | |
| 		client:     client,
 | |
| 		credential: client.GetCredential(),
 | |
| 	}, nil
 | |
| }
 | |
| 
 | |
| type Cos struct {
 | |
| 	copyURL    string
 | |
| 	client     *cos.Client
 | |
| 	credential *cos.Credential
 | |
| }
 | |
| 
 | |
| func (c *Cos) Engine() string {
 | |
| 	return "tencent-cos"
 | |
| }
 | |
| 
 | |
| func (c *Cos) PartLimit() *s3.PartLimit {
 | |
| 	return &s3.PartLimit{
 | |
| 		MinPartSize: minPartSize,
 | |
| 		MaxPartSize: maxPartSize,
 | |
| 		MaxNumSize:  maxNumSize,
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func (c *Cos) InitiateMultipartUpload(ctx context.Context, name string) (*s3.InitiateMultipartUploadResult, error) {
 | |
| 	result, _, err := c.client.Object.InitiateMultipartUpload(ctx, name, nil)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return &s3.InitiateMultipartUploadResult{
 | |
| 		UploadID: result.UploadID,
 | |
| 		Bucket:   result.Bucket,
 | |
| 		Key:      result.Key,
 | |
| 	}, nil
 | |
| }
 | |
| 
 | |
| func (c *Cos) CompleteMultipartUpload(ctx context.Context, uploadID string, name string, parts []s3.Part) (*s3.CompleteMultipartUploadResult, error) {
 | |
| 	opts := &cos.CompleteMultipartUploadOptions{
 | |
| 		Parts: make([]cos.Object, len(parts)),
 | |
| 	}
 | |
| 	for i, part := range parts {
 | |
| 		opts.Parts[i] = cos.Object{
 | |
| 			PartNumber: part.PartNumber,
 | |
| 			ETag:       strings.ReplaceAll(part.ETag, `"`, ``),
 | |
| 		}
 | |
| 	}
 | |
| 	result, _, err := c.client.Object.CompleteMultipartUpload(ctx, name, uploadID, opts)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return &s3.CompleteMultipartUploadResult{
 | |
| 		Location: result.Location,
 | |
| 		Bucket:   result.Bucket,
 | |
| 		Key:      result.Key,
 | |
| 		ETag:     result.ETag,
 | |
| 	}, nil
 | |
| }
 | |
| 
 | |
| func (c *Cos) PartSize(ctx context.Context, size int64) (int64, error) {
 | |
| 	if size <= 0 {
 | |
| 		return 0, errors.New("size must be greater than 0")
 | |
| 	}
 | |
| 	if size > maxPartSize*maxNumSize {
 | |
| 		return 0, fmt.Errorf("size must be less than %db", maxPartSize*maxNumSize)
 | |
| 	}
 | |
| 	if size <= minPartSize*maxNumSize {
 | |
| 		return minPartSize, nil
 | |
| 	}
 | |
| 	partSize := size / maxNumSize
 | |
| 	if size%maxNumSize != 0 {
 | |
| 		partSize++
 | |
| 	}
 | |
| 	return partSize, nil
 | |
| }
 | |
| 
 | |
| func (c *Cos) AuthSign(ctx context.Context, uploadID string, name string, expire time.Duration, partNumbers []int) (*s3.AuthSignResult, error) {
 | |
| 	result := s3.AuthSignResult{
 | |
| 		URL:    c.client.BaseURL.BucketURL.String() + "/" + cos.EncodeURIComponent(name),
 | |
| 		Query:  url.Values{"uploadId": {uploadID}},
 | |
| 		Header: make(http.Header),
 | |
| 		Parts:  make([]s3.SignPart, len(partNumbers)),
 | |
| 	}
 | |
| 	req, err := http.NewRequestWithContext(ctx, http.MethodPut, result.URL, nil)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	cos.AddAuthorizationHeader(c.credential.SecretID, c.credential.SecretKey, c.credential.SessionToken, req, cos.NewAuthTime(expire))
 | |
| 	result.Header = req.Header
 | |
| 	for i, partNumber := range partNumbers {
 | |
| 		result.Parts[i] = s3.SignPart{
 | |
| 			PartNumber: partNumber,
 | |
| 			Query:      url.Values{"partNumber": {strconv.Itoa(partNumber)}},
 | |
| 		}
 | |
| 	}
 | |
| 	return &result, nil
 | |
| }
 | |
| 
 | |
| func (c *Cos) PresignedPutObject(ctx context.Context, name string, expire time.Duration) (string, error) {
 | |
| 	rawURL, err := c.client.Object.GetPresignedURL(ctx, http.MethodPut, name, c.credential.SecretID, c.credential.SecretKey, expire, nil)
 | |
| 	if err != nil {
 | |
| 		return "", err
 | |
| 	}
 | |
| 	return rawURL.String(), nil
 | |
| }
 | |
| 
 | |
| func (c *Cos) DeleteObject(ctx context.Context, name string) error {
 | |
| 	_, err := c.client.Object.Delete(ctx, name)
 | |
| 	return err
 | |
| }
 | |
| 
 | |
| func (c *Cos) StatObject(ctx context.Context, name string) (*s3.ObjectInfo, error) {
 | |
| 	if name != "" && name[0] == '/' {
 | |
| 		name = name[1:]
 | |
| 	}
 | |
| 	info, err := c.client.Object.Head(ctx, name, nil)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	res := &s3.ObjectInfo{Key: name}
 | |
| 	if res.ETag = strings.ToLower(strings.ReplaceAll(info.Header.Get("ETag"), `"`, "")); res.ETag == "" {
 | |
| 		return nil, errors.New("StatObject etag not found")
 | |
| 	}
 | |
| 	if contentLengthStr := info.Header.Get("Content-Length"); contentLengthStr == "" {
 | |
| 		return nil, errors.New("StatObject content-length not found")
 | |
| 	} else {
 | |
| 		res.Size, err = strconv.ParseInt(contentLengthStr, 10, 64)
 | |
| 		if err != nil {
 | |
| 			return nil, fmt.Errorf("StatObject content-length parse error: %w", err)
 | |
| 		}
 | |
| 		if res.Size < 0 {
 | |
| 			return nil, errors.New("StatObject content-length must be greater than 0")
 | |
| 		}
 | |
| 	}
 | |
| 	if lastModified := info.Header.Get("Last-Modified"); lastModified == "" {
 | |
| 		return nil, errors.New("StatObject last-modified not found")
 | |
| 	} else {
 | |
| 		res.LastModified, err = time.Parse(http.TimeFormat, lastModified)
 | |
| 		if err != nil {
 | |
| 			return nil, fmt.Errorf("StatObject last-modified parse error: %w", err)
 | |
| 		}
 | |
| 	}
 | |
| 	return res, nil
 | |
| }
 | |
| 
 | |
| func (c *Cos) CopyObject(ctx context.Context, src string, dst string) (*s3.CopyObjectInfo, error) {
 | |
| 	sourceURL := c.copyURL + src
 | |
| 	result, _, err := c.client.Object.Copy(ctx, dst, sourceURL, nil)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return &s3.CopyObjectInfo{
 | |
| 		Key:  dst,
 | |
| 		ETag: strings.ReplaceAll(result.ETag, `"`, ``),
 | |
| 	}, nil
 | |
| }
 | |
| 
 | |
| func (c *Cos) IsNotFound(err error) bool {
 | |
| 	switch e := err.(type) {
 | |
| 	case *cos.ErrorResponse:
 | |
| 		return e.Response.StatusCode == http.StatusNotFound || e.Code == "NoSuchKey"
 | |
| 	default:
 | |
| 		return false
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func (c *Cos) AbortMultipartUpload(ctx context.Context, uploadID string, name string) error {
 | |
| 	_, err := c.client.Object.AbortMultipartUpload(ctx, name, uploadID)
 | |
| 	return err
 | |
| }
 | |
| 
 | |
| func (c *Cos) ListUploadedParts(ctx context.Context, uploadID string, name string, partNumberMarker int, maxParts int) (*s3.ListUploadedPartsResult, error) {
 | |
| 	result, _, err := c.client.Object.ListParts(ctx, name, uploadID, &cos.ObjectListPartsOptions{
 | |
| 		MaxParts:         strconv.Itoa(maxParts),
 | |
| 		PartNumberMarker: strconv.Itoa(partNumberMarker),
 | |
| 	})
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	res := &s3.ListUploadedPartsResult{
 | |
| 		Key:           result.Key,
 | |
| 		UploadID:      result.UploadID,
 | |
| 		UploadedParts: make([]s3.UploadedPart, len(result.Parts)),
 | |
| 	}
 | |
| 	res.MaxParts, _ = strconv.Atoi(result.MaxParts)
 | |
| 	res.NextPartNumberMarker, _ = strconv.Atoi(result.NextPartNumberMarker)
 | |
| 	for i, part := range result.Parts {
 | |
| 		lastModified, _ := time.Parse(http.TimeFormat, part.LastModified)
 | |
| 		res.UploadedParts[i] = s3.UploadedPart{
 | |
| 			PartNumber:   part.PartNumber,
 | |
| 			LastModified: lastModified,
 | |
| 			ETag:         part.ETag,
 | |
| 			Size:         part.Size,
 | |
| 		}
 | |
| 	}
 | |
| 	return res, nil
 | |
| }
 | |
| 
 | |
| func (c *Cos) AccessURL(ctx context.Context, name string, expire time.Duration, opt *s3.AccessURLOption) (string, error) {
 | |
| 	var imageMogr string
 | |
| 	var option cos.PresignedURLOptions
 | |
| 	if opt != nil {
 | |
| 		query := make(url.Values)
 | |
| 		if opt.Image != nil {
 | |
| 			// https://cloud.tencent.com/document/product/436/44880
 | |
| 			style := make([]string, 0, 2)
 | |
| 			wh := make([]string, 2)
 | |
| 			if opt.Image.Width > 0 {
 | |
| 				wh[0] = strconv.Itoa(opt.Image.Width)
 | |
| 			}
 | |
| 			if opt.Image.Height > 0 {
 | |
| 				wh[1] = strconv.Itoa(opt.Image.Height)
 | |
| 			}
 | |
| 			if opt.Image.Width > 0 || opt.Image.Height > 0 {
 | |
| 				style = append(style, strings.Join(wh, "x"))
 | |
| 			}
 | |
| 			switch opt.Image.Format {
 | |
| 			case
 | |
| 				imagePng,
 | |
| 				imageJpg,
 | |
| 				imageJpeg,
 | |
| 				imageGif,
 | |
| 				imageWebp:
 | |
| 				style = append(style, "format/"+opt.Image.Format)
 | |
| 			}
 | |
| 			if len(style) > 0 {
 | |
| 				imageMogr = "imageMogr2/thumbnail/" + strings.Join(style, "/") + "/ignore-error/1"
 | |
| 			}
 | |
| 		}
 | |
| 		if opt.ContentType != "" {
 | |
| 			query.Set("response-content-type", opt.ContentType)
 | |
| 		}
 | |
| 		if opt.Filename != "" {
 | |
| 			query.Set("response-content-disposition", `attachment; filename=`+strconv.Quote(opt.Filename))
 | |
| 		}
 | |
| 		if len(query) > 0 {
 | |
| 			option.Query = &query
 | |
| 		}
 | |
| 	}
 | |
| 	if expire <= 0 {
 | |
| 		expire = time.Hour * 24 * 365 * 99 // 99 years
 | |
| 	} else if expire < time.Second {
 | |
| 		expire = time.Second
 | |
| 	}
 | |
| 	rawURL, err := c.getPresignedURL(ctx, name, expire, &option)
 | |
| 	if err != nil {
 | |
| 		return "", err
 | |
| 	}
 | |
| 	if imageMogr != "" {
 | |
| 		if rawURL.RawQuery == "" {
 | |
| 			rawURL.RawQuery = imageMogr
 | |
| 		} else {
 | |
| 			rawURL.RawQuery = rawURL.RawQuery + "&" + imageMogr
 | |
| 		}
 | |
| 	}
 | |
| 	return rawURL.String(), nil
 | |
| }
 | |
| 
 | |
| func (c *Cos) getPresignedURL(ctx context.Context, name string, expire time.Duration, opt *cos.PresignedURLOptions) (*url.URL, error) {
 | |
| 	if !config.Config.Object.Cos.PublicRead {
 | |
| 		return c.client.Object.GetPresignedURL(ctx, http.MethodGet, name, c.credential.SecretID, c.credential.SecretKey, expire, opt)
 | |
| 	}
 | |
| 	return c.client.Object.GetObjectURL(name), nil
 | |
| }
 |