s3地址问题
This commit is contained in:
parent
a1890c7562
commit
087def8015
@ -7,6 +7,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
"log"
|
||||
"path"
|
||||
"sort"
|
||||
"time"
|
||||
@ -74,11 +75,22 @@ func (s *S3Adapter) GetFileList(dirPath string, relDt time.Time) ([]dto.File, er
|
||||
if startTime.Equal(stopTime) || stopTime.IsZero() {
|
||||
stopTime = stopTime.Add(time.Second * time.Duration(config.Config.Record.Duration))
|
||||
}
|
||||
presignClient := s3.NewPresignClient(client)
|
||||
request, err := presignClient.PresignGetObject(context.TODO(), &s3.GetObjectInput{
|
||||
Bucket: aws.String(s.StorageConfig.S3.Bucket),
|
||||
Key: aws.String(key),
|
||||
}, func(presignOptions *s3.PresignOptions) {
|
||||
presignOptions.Expires = 10 * time.Minute
|
||||
})
|
||||
if err != nil {
|
||||
log.Println("Error presigning GetObject request:", err)
|
||||
continue
|
||||
}
|
||||
fileList = append(fileList, dto.File{
|
||||
BasePath: s.StorageConfig.S3.Bucket,
|
||||
Name: path.Base(key),
|
||||
Path: path.Dir(key),
|
||||
Url: key,
|
||||
Url: request.URL,
|
||||
StartTime: startTime,
|
||||
EndTime: stopTime,
|
||||
})
|
||||
|
@ -3,13 +3,15 @@ package util
|
||||
import (
|
||||
"ZhenTuLocalPassiveAdapter/config"
|
||||
"fmt"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ParseStartStopTime(filePath string, relativeDate time.Time) (time.Time, time.Time, error) {
|
||||
split := strings.Split(filePath, config.Config.FileName.TimeSplit)
|
||||
_, file := path.Split(filePath)
|
||||
split := strings.Split(file, config.Config.FileName.TimeSplit)
|
||||
if len(split) == 0 {
|
||||
return time.Time{}, time.Time{}, fmt.Errorf("无法解析时间范围")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user