added metadata
This commit is contained in:
@@ -3,6 +3,7 @@ package s3
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.kapelle.org/niklas/s3share/internal/types"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -54,3 +55,15 @@ func (m *minioClient) KeyExists(ctx context.Context, key string) (bool, error) {
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (m *minioClient) GetObjectMetadata(ctx context.Context, key string) (*types.Metadata, error) {
|
||||
object, err := m.client.StatObject(ctx, m.bucket, key, minio.StatObjectOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.Metadata{
|
||||
Size: object.Size,
|
||||
ContentType: object.ContentType,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package s3
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"git.kapelle.org/niklas/s3share/internal/types"
|
||||
)
|
||||
|
||||
type ObjectReader interface {
|
||||
@@ -15,4 +17,5 @@ type ObjectReader interface {
|
||||
type S3 interface {
|
||||
GetObject(ctx context.Context, key string) (ObjectReader, error)
|
||||
KeyExists(ctx context.Context, key string) (bool, error)
|
||||
GetObjectMetadata(ctx context.Context, key string) (*types.Metadata, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user