This commit is contained in:
binwiederhier
2026-03-17 20:53:41 -04:00
parent cffa57950a
commit ef314960d0
16 changed files with 682 additions and 436 deletions
+9 -1
View File
@@ -196,7 +196,15 @@ func (c *Client) ListObjects(ctx context.Context, continuationToken string, maxK
}
objects := make([]Object, len(result.Contents))
for i, obj := range result.Contents {
objects[i] = Object(obj)
var lastModified time.Time
if obj.LastModified != "" {
lastModified, _ = time.Parse(time.RFC3339, obj.LastModified)
}
objects[i] = Object{
Key: obj.Key,
Size: obj.Size,
LastModified: lastModified,
}
}
return &ListResult{
Objects: objects,
+2 -1
View File
@@ -13,6 +13,7 @@ import (
"strings"
"sync"
"testing"
"time"
"github.com/stretchr/testify/require"
)
@@ -243,7 +244,7 @@ func (m *mockS3Server) handleList(w http.ResponseWriter, r *http.Request, bucket
var contents []listObject
for _, objKey := range allKeys {
body := m.objects[bucketPath+"/"+objKey]
contents = append(contents, listObject{Key: objKey, Size: int64(len(body))})
contents = append(contents, listObject{Key: objKey, Size: int64(len(body)), LastModified: time.Now().Format(time.RFC3339)})
}
m.mu.RUnlock()
+10 -5
View File
@@ -1,6 +1,9 @@
package s3
import "fmt"
import (
"fmt"
"time"
)
// Config holds the parsed fields from an S3 URL. Use ParseURL to create one from a URL string.
type Config struct {
@@ -15,8 +18,9 @@ type Config struct {
// Object represents an S3 object returned by list operations.
type Object struct {
Key string
Size int64
Key string
Size int64
LastModified time.Time
}
// ListResult holds the response from a ListObjectsV2 call.
@@ -49,8 +53,9 @@ type listObjectsV2Response struct {
}
type listObject struct {
Key string `xml:"Key"`
Size int64 `xml:"Size"`
Key string `xml:"Key"`
Size int64 `xml:"Size"`
LastModified string `xml:"LastModified"`
}
// deleteResult is the XML response from S3 DeleteObjects