file-system/internal/domain/repository/file_repository.go
向宁 b5df6445e5 refactor: commit all pending file_system changes
- Restructure handlers into file_commands/file_queries/file_handlers
- Add gRPC auth client, JWT middleware, rate limiting, request ID
- Add common utilities: logger, sanitizer, s3_errors
- Add unit tests for config, mediator, auth, request_id, sanitize
- Add proto definitions and generated code
- Remove old web UI pages
- Add .dockerignore and .env.example
2026-05-17 22:20:02 +08:00

45 lines
1.7 KiB
Go

package repository
import (
"context"
"rag/file-system/internal/common"
"io"
"time"
)
type FileInfo struct {
Key string
Size int64
LastModified time.Time
ETag string
}
type ListFilesResult struct {
Files []FileInfo
NextContinuationToken *string
}
type FileRepository interface {
UploadFile(ctx context.Context, bucketName string, objectKey string, data io.Reader) error
DownloadFile(ctx context.Context, bucketName string, objectKey string) (io.ReadCloser, error)
ListBuckets(ctx context.Context) ([]string, error)
CreateBucket(ctx context.Context, bucketName string) error
DeleteBucket(ctx context.Context, bucketName string) error
// File listing with pagination
ListObjectsV2(ctx context.Context, bucketName string, prefix string, maxKeys int32, continuationToken *string) (*ListFilesResult, error)
GeneratePresignedURL(ctx context.Context, bucketName string, objectKey string, expiry time.Duration) (string, error)
// File content retrieval for text preview
GetFileContent(ctx context.Context, bucketName string, objectKey string) (string, error)
// File deletion
DeleteFile(ctx context.Context, bucketName string, objectKey string) error
// Multipart upload
CreateMultipartUpload(ctx context.Context, bucketName string, objectKey string) (string, error)
UploadPart(ctx context.Context, bucketName string, objectKey string, uploadId string, partNumber int32, data io.Reader) (string, error)
CompleteMultipartUpload(ctx context.Context, bucketName string, objectKey string, uploadId string, parts []common.Part) (string, error)
AbortMultipartUpload(ctx context.Context, bucketName string, objectKey string, uploadId string) error
}