s3循环列表
This commit is contained in:
parent
087def8015
commit
06f7e007f0
@ -57,12 +57,20 @@ func (s *S3Adapter) GetFileList(dirPath string, relDt time.Time) ([]dto.File, er
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var fileList []dto.File
|
||||
var continuationToken *string
|
||||
|
||||
for {
|
||||
if continuationToken != nil {
|
||||
listObjectsInput.ContinuationToken = continuationToken
|
||||
}
|
||||
|
||||
result, err := client.ListObjectsV2(context.TODO(), listObjectsInput)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var fileList []dto.File
|
||||
for _, object := range result.Contents {
|
||||
key := *object.Key
|
||||
if !util.IsVideoFile(path.Base(key)) {
|
||||
@ -95,6 +103,13 @@ func (s *S3Adapter) GetFileList(dirPath string, relDt time.Time) ([]dto.File, er
|
||||
EndTime: stopTime,
|
||||
})
|
||||
}
|
||||
|
||||
if !*result.IsTruncated {
|
||||
break
|
||||
}
|
||||
continuationToken = result.NextContinuationToken
|
||||
}
|
||||
|
||||
sort.Slice(fileList, func(i, j int) bool {
|
||||
return fileList[i].StartTime.Before(fileList[j].StartTime)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user